public async Task <IdentityProviderAuthResponse> GetToken(IdentityProviderAuthCodeDetails authCode) { var queryParams = new Dictionary <string, string>() { { "grant_type", "authorization_code" }, { "code", authCode.Code }, { "redirect_uri", authCode.RedirectUri }, { "client_id", ClientId }, { "client_secret", ClientSecret }, { "include_granted_scopes", "true" } // optional }; var client = _clientFactory.CreateClient(); string uri = QueryHelpers.AddQueryString(TokenEndpoint, queryParams); var request = new HttpRequestMessage(HttpMethod.Post, uri); request.Content = new StringContent("", Encoding.UTF8, "application/x-www-form-urlencoded"); var response = await client.SendAsync(request); string jsonResult = await response.Content.ReadAsStringAsync(); return(ConvertResultToAuthResponse(jsonResult)); }
public async Task <IActionResult> AuthWithGoogleAsync(IdentityProviderAuthCodeDetails authCode) { IdentityProviderAuthResponse authResponse = await _googleAuth.GetToken(authCode); User user = _userStore.UpsertFromGoogleAuth(authResponse); bool hasRedirectUri = !String.IsNullOrWhiteSpace(authCode.ClientRedirectUri); string redirectUri = hasRedirectUri ? $"{authCode.ClientRedirectUri}?auth_code={user.AuthCode}" : null; return(Ok(new { client_redirect_uri = redirectUri, auth_code = user.AuthCode })); }
public async Task <IdentityProviderAuthResponse> RefreshToken(IdentityProviderAuthCodeDetails authCode) { throw new NotImplementedException(); }