getTokenWithSocialGrantFlow method

Future<AccessTokenResponse> getTokenWithSocialGrantFlow({
  1. required String clientId,
  2. required String clientSecret,
  3. List<String>? scopes,
  4. required String providerName,
  5. required String providerAccessToken,
  6. dynamic httpClient,
})

Requests an Access Token to the OAuth2 endpoint using the Social Grant flow.

Implementation

Future<AccessTokenResponse> getTokenWithSocialGrantFlow(
    {required String clientId,
    required String clientSecret,
    List<String>? scopes,
    required String providerName,
    required String providerAccessToken,
    httpClient}) async {
  var params = <String, String>{
    'grant_type': 'social',
    'provider': providerName!,
    'access_token': providerAccessToken!
    };

  if (scopes != null && scopes.isNotEmpty) {
    params['scope'] = serializeScopes(scopes);
  }

  var response = await _performAuthorizedRequest(
      url: tokenUrl,
      clientId: clientId,
      clientSecret: clientSecret,
      params: params,
      httpClient: httpClient);

  return http2TokenResponse(response, requestedScopes: scopes);
}