isWrappedBearerAuthHeaderValue function

bool isWrappedBearerAuthHeaderValue(
  1. String value
)

Returns true if the provided value is a Bearer auth header value.

Implementation

bool isWrappedBearerAuthHeaderValue(String value) {
  var parts = value.split(' ');
  if (parts[0].toLowerCase() != bearerAuthSchemeName.toLowerCase()) {
    return false;
  }
  // if the value starts with the bearer scheme, it must be valid and wrapped or we throw for invalid query
  if (parts.length == 2) {
    return true;
  } else {
    throw AuthHeaderEncodingException(
      'Invalid "bearer" auth scheme value "$value"',
    );
  }
}