Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Support id_token responses in JwtFlow
Browse files Browse the repository at this point in the history
  • Loading branch information
Schwusch committed Sep 4, 2020
1 parent 9c2bb89 commit 2b02329
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/src/oauth2_flows/jwt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ class JwtFlow {
.transform(json.decoder)
.first;
Map response = object as Map;
var tokenType = response['token_type'];
var token = response['access_token'];
var expiresIn = response['expires_in'];
String tokenType = response['token_type'];
String token = response['access_token'];
int expiresIn = response['expires_in'];
var error = response['error'];

if(response['id_token'] != null) {
tokenType = 'Bearer';
token = response['id_token'];
final payloadB64 = token.split('.')[1];
final decoded = jsonDecode(ascii.decode(base64Decode(base64.normalize(payloadB64))));
expiresIn = decoded['exp'] * 1000;
}

if (httpResponse.statusCode != 200 && error != null) {
throw new Exception('Unable to obtain credentials. Error: $error.');
}
Expand Down

0 comments on commit 2b02329

Please sign in to comment.