determineAuthType function

AuthType determineAuthType(
  1. Map<String, String> authHeaders
)

Determine the type of auth based on authHeaders.

  • authHeaders auth headers Map.

Returns AuthType enum.

Implementation

AuthType determineAuthType(Map<String, String> authHeaders) {
  var authType = AuthType.oauthCustomClient;

  if (OAuthToken.isOAuth(authHeaders)) {
    authType = AuthType.oauthCustomClient;
  }

  if (authHeaders.containsKey('authorization')) {
    final authorization = authHeaders['authorization']!;
    if (authorization.contains('SAPISIDHASH')) {
      authType = AuthType.browser;
    } else if (authorization.startsWith('Bearer')) {
      authType = AuthType.oauthCustomFull;
    }
  }
  return authType;
}