public async Task TokenRevokeTaskAsync(string accessToken)
        {
            var requestModel = new AuthTokenRequestModel
            {
                AccessToken = accessToken,
                ClientToken = LauncherProfileParser.LauncherProfile.ClientToken
            };
            var requestJson = JsonConvert.SerializeObject(requestModel, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            _ = await HttpHelper.Post(RevokeAddress, requestJson).ConfigureAwait(true);
        }
        public async Task <bool> ValidateTokenTaskAsync(string accessToken)
        {
            var requestModel = new AuthTokenRequestModel
            {
                AccessToken = accessToken,
                ClientToken = LauncherProfileParser.LauncherProfile.ClientToken
            };
            var requestJson = JsonConvert.SerializeObject(requestModel, new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            var result = await HttpHelper.Post(ValidateAddress, requestJson).ConfigureAwait(true);

            return(result.StatusCode.Equals(HttpStatusCode.NoContent));
        }
Example #3
0
        public async Task <AuthTokenResponseModel> PostToken([FromBody] AuthTokenRequestModel model)
        {
            var result = await _signInManager.PasswordSignInAsync(model.Email.ToLower(), model.MasterPasswordHash, model.Device?.ToDevice());

            if (result == JwtBearerSignInResult.Success)
            {
                return(new AuthTokenResponseModel(result.Token, result.User));
            }
            else if (result == JwtBearerSignInResult.TwoFactorRequired)
            {
                return(new AuthTokenResponseModel(result.Token, null));
            }

            await Task.Delay(2000);

            throw new BadRequestException("Username or password is incorrect. Try again.");
        }