OpenID's id_token implementation
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b0767a2..3827b2b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.2.4
+
+* OpenID's id_token treated.
+
# 1.2.3
* Support the latest `package:http` release.
diff --git a/lib/src/credentials.dart b/lib/src/credentials.dart
index 343f12d..9e575f7 100644
--- a/lib/src/credentials.dart
+++ b/lib/src/credentials.dart
@@ -41,6 +41,14 @@
/// This may be `null`, indicating that the credentials can't be refreshed.
final String refreshToken;
+ /// The token that is received from the authorization server to enable
+ /// End-Users to be Authenticated, contains Claims, represented as a
+ /// JSON Web Token (JWT).
+ ///
+ /// [spec]: https://openid.net/specs/openid-connect-core-1_0.html#IDToken
+ /// This may be `null`, indicating that the openid scope is not implemented.
+ final String idToken;
+
/// The URL of the authorization server endpoint that's used to refresh the
/// credentials.
///
@@ -95,6 +103,7 @@
/// [standard JSON response]: https://tools.ietf.org/html/rfc6749#section-5.1
Credentials(this.accessToken,
{this.refreshToken,
+ this.idToken,
this.tokenEndpoint,
Iterable<String> scopes,
this.expiration,
@@ -132,7 +141,7 @@
'required field "accessToken" was not a string, was '
'${parsed["accessToken"]}');
- for (var stringField in ['refreshToken', 'tokenEndpoint']) {
+ for (var stringField in ['refreshToken', 'idToken', 'tokenEndpoint']) {
var value = parsed[stringField];
validate(value == null || value is String,
'field "$stringField" was not a string, was "$value"');
@@ -155,6 +164,7 @@
return new Credentials(parsed['accessToken'],
refreshToken: parsed['refreshToken'],
+ idToken: parsed['idToken'],
tokenEndpoint: tokenEndpoint,
scopes: (scopes as List).map((scope) => scope as String),
expiration: expiration);
@@ -167,6 +177,7 @@
String toJson() => jsonEncode({
'accessToken': accessToken,
'refreshToken': refreshToken,
+ 'idToken': idToken,
'tokenEndpoint':
tokenEndpoint == null ? null : tokenEndpoint.toString(),
'scopes': scopes,
@@ -233,6 +244,7 @@
if (credentials.refreshToken != null) return credentials;
return new Credentials(credentials.accessToken,
refreshToken: this.refreshToken,
+ idToken: credentials.idToken,
tokenEndpoint: credentials.tokenEndpoint,
scopes: credentials.scopes,
expiration: credentials.expiration);
diff --git a/lib/src/handle_access_token_response.dart b/lib/src/handle_access_token_response.dart
index ca4896e..851475a 100644
--- a/lib/src/handle_access_token_response.dart
+++ b/lib/src/handle_access_token_response.dart
@@ -72,7 +72,7 @@
'parameter "expires_in" was not an int, was "$expiresIn"');
}
- for (var name in ['refresh_token', 'scope']) {
+ for (var name in ['refresh_token', 'id_token', 'scope']) {
var value = parameters[name];
if (value != null && value is! String)
throw new FormatException(
@@ -88,6 +88,7 @@
return new Credentials(parameters['access_token'],
refreshToken: parameters['refresh_token'],
+ idToken: parameters['id_token'],
tokenEndpoint: tokenEndpoint,
scopes: scopes,
expiration: expiration);
diff --git a/pubspec.yaml b/pubspec.yaml
index 6e9d47f..9da666f 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: oauth2
-version: 1.2.3
+version: 1.2.4
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/oauth2
description: >-