Dart Documentationgoogle_oauth2_browserSimpleOAuth2

SimpleOAuth2 class

A simple OAuth2 authentication context which can use if you already have a token via another mechanism, like f.e. the Chrome Extension Identity API

class SimpleOAuth2 extends OAuth2 {
 String token;
 String tokenType;

 /// Creates an OAuth2 context for the application using [token] for authentication
 SimpleOAuth2(String this.token, {String this.tokenType: "Bearer"}) : super();

 Future<HttpRequest> authenticate(HttpRequest request) {
   request.setRequestHeader("Authorization", "${tokenType} ${token}");
   return new Future.value(request);
 }
}

Extends

OAuth2 > SimpleOAuth2

Constructors

new SimpleOAuth2(String token, {String tokenType: "Bearer"}) #

Creates an OAuth2 context for the application using token for authentication

SimpleOAuth2(String this.token, {String this.tokenType: "Bearer"}) : super();

Properties

String token #

String token

String tokenType #

String tokenType

Methods

Future<HttpRequest> authenticate(HttpRequest request) #

Take a request and return the request with the authorization headers set correctly

docs inherited from OAuth2
Future<HttpRequest> authenticate(HttpRequest request) {
 request.setRequestHeader("Authorization", "${tokenType} ${token}");
 return new Future.value(request);
}