isOAuthAuthorizationError property

bool isOAuthAuthorizationError

If is an OAuth Authorization Error. Only if response contains a JSON with matching entries and status is: 0, 400 or 401.

Since OAuth uses status 400 to return an Authorization error, this is useful to identify that.

Implementation

bool get isOAuthAuthorizationError {
  if (!hasMessage) return false;

  var authorizationCode = status == 0 || status == 400 || status == 401;
  if (!authorizationCode) return false;

  return matchesAnyJSONEntry('error',
      ['invalid_grant', 'invalid_client', 'unauthorized_client'], true);
}