I am using Blazor Webassembly standalone + Asp.Net Web Api(.Net8.0). I want to implement Google Authentiaction. I successfully got the authorization code but having a problemgetting the access token and id token.I am referring to Google OpenId Connect.I have used this code...
var authCode = "4/0AanRRrsWBIJ~~~~~~~~~~~~";var clientId = configuration.GetValue<string>("Authentication:Google:ClientId") ?? string.Empty;var clientSecret = configuration.GetValue<string> ("Authentication:Google:ClientSecret") ?? string.Empty;var redirectUri = "https://localhost:7210/authentication/login-callback";var tokenUri = "https://oauth2.googleapis.com/token";var parameters = new Dictionary<string, string>{ { "code", authCode }, { "client_id", clientId }, { "client_secret", clientSecret }, { "redirect_uri", redirectUri }, { "grant_type", "authorization_code" }};var content = new FormUrlEncodedContent(parameters);var httpClient = httpClientFactory.CreateClient();var response = await httpClient.PostAsync(tokenUri, content);But, I got the error;
StatusCode: 400
ReasonPhrase: 'Bad Request'
Thank you in advance for any help.
[What I tried]
When I manually create OpenID Connect authentication URI(no PKCE), adding this code make it work.
httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));)But, when I use RemoteAuthenticatorView to send an authentication request to Google(with PKCE), it doesn't work.
Is PKCE the cause?Or RemoteAuthenticatorView?