getToken static method
Future<BungieNetToken>
getToken(
- HttpClient client,
- String clientId,
- String clientSecret,
- String code,
Implementation
static Future<BungieNetToken> getToken(
HttpClient client, String clientId, String clientSecret, String code) {
final HttpClientConfig config =
HttpClientConfig('POST', '/App/OAuth/token/', null);
config.bodyContentType = 'application/x-www-form-urlencoded';
config.body =
'client_id=$clientId&client_secret=$clientSecret&code=$code&grant_type=authorization_code';
return client.request(config).then((HttpResponse response) {
if (response.statusCode == 200) {
return BungieNetToken.fromJson(response.mappedBody);
}
throw OAuthException(response.mappedBody['error'],
response.mappedBody['error_description']);
});
}