Returns a Authorization for accessToken
.
This method obtains an AuthToken for accessToken
from storage and then verifies that the token is valid.
If the token is valid, an Authorization object is returned. Otherwise, null
is returned.
Source
Future<Authorization> verify(String accessToken, {List<AuthScope> scopesRequired}) async { if (accessToken == null) { return null; } AuthToken t = await storage.fetchTokenByAccessToken(this, accessToken); if (t == null || t.isExpired) { return null; } if (scopesRequired != null) { var hasAllRequiredScopes = scopesRequired.every((requiredScope) { var tokenHasValidScope = t.scopes ?.any((tokenScope) => requiredScope.allowsScope(tokenScope)); return tokenHasValidScope ?? false; }); if (!hasAllRequiredScopes) { return null; } } return new Authorization(t.clientID, t.resourceOwnerIdentifier, this, scopes: t.scopes); }