2017-10-16 06:38:46 +00:00
|
|
|
/// Represents an OAuth2 authorization token.
|
|
|
|
class AuthorizationTokenResponse {
|
|
|
|
/// The string that third parties should use to act on behalf of the user in question.
|
2017-09-29 02:16:44 +00:00
|
|
|
final String accessToken;
|
2017-10-16 06:38:46 +00:00
|
|
|
|
|
|
|
/// An optional key that can be used to refresh the [accessToken] past its expiration.
|
2017-09-29 02:16:44 +00:00
|
|
|
final String refreshToken;
|
|
|
|
|
2017-10-16 06:38:46 +00:00
|
|
|
/// An optional, but recommended integer that signifies the time left until the [accessToken] expires.
|
|
|
|
final int expiresIn;
|
|
|
|
|
|
|
|
/// Optional, if identical to the scope requested by the client; otherwise, required.
|
|
|
|
final Iterable<String> scope;
|
|
|
|
|
|
|
|
const AuthorizationTokenResponse(this.accessToken,
|
|
|
|
{this.refreshToken, this.expiresIn, this.scope});
|
2017-09-29 02:16:44 +00:00
|
|
|
|
2017-10-16 06:38:46 +00:00
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
var map = <String, dynamic>{'access_token': accessToken};
|
2017-09-29 02:16:44 +00:00
|
|
|
if (refreshToken?.isNotEmpty == true) map['refresh_token'] = refreshToken;
|
2017-10-16 06:38:46 +00:00
|
|
|
if (expiresIn != null) map['expires_in'] = expiresIn;
|
|
|
|
if (scope != null) map['scope'] = scope.toList();
|
2017-09-29 02:16:44 +00:00
|
|
|
return map;
|
|
|
|
}
|
2017-10-16 06:38:46 +00:00
|
|
|
}
|