private async Task <OAuth2TokenResponse> SendHttpMessageAsync(OAuth2Client client, Uri tokenEndpoint) { UriBuilder builder = new UriBuilder(tokenEndpoint); builder.AppendQueryParameters(AuthenticationRequestParameters.ExtraQueryParameters); OAuth2TokenResponse authTokenResponse = await client .GetTokenAsync( builder.Uri, AuthenticationRequestParameters.RequestContext) .ConfigureAwait(false); if (string.IsNullOrEmpty(authTokenResponse.Scope)) { authTokenResponse.Scope = AuthenticationRequestParameters.Scope.AsSingleString(); AuthenticationRequestParameters.RequestContext.Logger.Info("ScopeSet was missing from the token response, so using developer provided scopes in the result"); } return(authTokenResponse); }
protected async Task <OAuth2TokenResponse> SendTokenRequestAsync( Uri tokenEndpoint, IDictionary <string, string> additionalBodyParameters, CancellationToken cancellationToken) { OAuth2Client client = new OAuth2Client(ServiceBundle.HttpManager); client.AddBodyParameter(OAuth2Parameter.ClientId, AuthenticationRequestParameters.ClientId); client.AddBodyParameter(OAuth2Parameter.ClientInfo, "1"); client.AddBodyParameter(OAuth2Parameter.Scope, GetDecoratedScope(AuthenticationRequestParameters.Scope).AsSingleString()); client.AddQueryParameter(OAuth2Parameter.Claims, AuthenticationRequestParameters.Claims); foreach (var kvp in additionalBodyParameters) { client.AddBodyParameter(kvp.Key, kvp.Value); } return(await SendHttpMessageAsync(client, tokenEndpoint).ConfigureAwait(false)); }