Beispiel #1
0
        public async Task <IActionResult> Access_token(Access_tokenAddressModel model)
        {
            var AppState = await OAuthService.CorrectAppAsync(model.AppId, model.AppSecret);

            if (AppState.code != 0)
            {
                return(Json(AppState));
            }
            var _targetPack = await _dbContext.OAuthPack.SingleOrDefaultAsync(t => t.Code == model.Code);

            if (_targetPack == null)
            {
                return(Json(new AiurProtocal {
                    message = "Invalid Code.", code = -2
                }));
            }
            if (_targetPack.ApplyAppId != model.AppId)
            {
                return(Json(new AiurProtocal {
                    message = "The app granted code is not the app granting access token!", code = -3
                }));
            }
            var _newAccessToken = new AccessToken
            {
                OAuthPack = _targetPack,
                PackId    = _targetPack.OAuthPackId,
                Value     = (DateTime.Now.ToString() + model.AppId).GetMD5()
            };

            _dbContext.AccessToken.Add(_newAccessToken);
            await _dbContext.SaveChangesAsync();

            var _model = new AuthAccessToken
            {
                access_token  = _newAccessToken.Value,
                openid        = _targetPack.UserId,
                expires_in    = 7200,
                refresh_token = "not implemented!",
                scope         = "scope"
            };

            return(Json(_model));
        }
Beispiel #2
0
 public string createRefreshToken(User user, AuthAccessToken authAccessToken)
 {
     throw new NotImplementedException();
 }