public class TokenResponse
OAuth 2.0 model for a successful access token response as specified in http://tools.ietf.org/html/rfc6749#section-5.1.
Namespace
Google.Apis.Auth.OAuth2.ResponsesAssembly
Google.Apis.Auth.dll
Properties
AccessToken
[JsonProperty("access_token")]
public string AccessToken { get; set; }
Gets or sets the access token issued by the authorization server.
Property Value | |
---|---|
Type | Description |
string |
ExpiresInSeconds
[JsonProperty("expires_in")]
public long? ExpiresInSeconds { get; set; }
Gets or sets the lifetime in seconds of the access token.
Property Value | |
---|---|
Type | Description |
long |
IdToken
[JsonProperty("id_token")]
public string IdToken { get; set; }
Gets or sets the id_token, which is a JSON Web Token (JWT) as specified in http://tools.ietf.org/html/draft-ietf-oauth-json-web-token
Property Value | |
---|---|
Type | Description |
string |
IsStale
[JsonIgnore]
public bool IsStale { get; }
Returns true if the token represented by this token response should be refreshed. Note that this may be true for valid tokens, in which case a pre-emptive refresh is adviced even if the current token may be used while it continues to be valid.
Property Value | |
---|---|
Type | Description |
bool |
See MayBeUsed(IClock) for information on when a token is considered valid. A valid token is considered stale if it's close to expiring, but not so much as to be unusable.
Issued
[Obsolete("Use IssuedUtc instead")]
[JsonProperty(Order = 1)]
public DateTime Issued { get; set; }
The date and time that this token was issued, expressed in the system time zone. This property only exists for backward compatibility; it can cause inappropriate behavior around time zone transitions (e.g. daylight saving transitions).
Property Value | |
---|---|
Type | Description |
DateTime |
IssuedUtc
[JsonProperty(Order = 2)]
public DateTime IssuedUtc { get; set; }
The date and time that this token was issued, expressed in UTC.
Property Value | |
---|---|
Type | Description |
DateTime |
This should be set by the CLIENT after the token was received from the server.
RefreshToken
[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }
Gets or sets the refresh token which can be used to obtain a new access token. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated.
Property Value | |
---|---|
Type | Description |
string |
Scope
[JsonProperty("scope")]
public string Scope { get; set; }
Gets or sets the scope of the access token as specified in http://tools.ietf.org/html/rfc6749#section-3.3.
Property Value | |
---|---|
Type | Description |
string |
TokenType
[JsonProperty("token_type")]
public string TokenType { get; set; }
Gets or sets the token type as specified in http://tools.ietf.org/html/rfc6749#section-7.1.
Property Value | |
---|---|
Type | Description |
string |
Methods
FromHttpResponseAsync(HttpResponseMessage, IClock, ILogger)
public static Task<TokenResponse> FromHttpResponseAsync(HttpResponseMessage response, IClock clock, ILogger logger)
Asynchronously parses a TokenResponse instance from the specified HttpResponseMessage.
Parameters | |
---|---|
Name | Description |
response |
HttpResponseMessage The http response from which to parse the token. |
clock |
IClock The clock used to set the Issued value of the token. |
logger |
ILogger The logger used to output messages incase of error. |
Returns | |
---|---|
Type | Description |
TaskTokenResponse |
A task containing the TokenResponse parsed form the response message. |
Exceptions | |
---|---|
Type | Description |
TokenResponseException |
The response was not successful or there is an error parsing the response into valid TokenResponse instance. |
IsExpired(IClock)
[Obsolete("Please use the TokenResponse.IsStale property instead.")]
public bool IsExpired(IClock clock)
Returns true if the token is expired or it's going to expire soon.
Parameter | |
---|---|
Name | Description |
clock |
IClock |
Returns | |
---|---|
Type | Description |
bool |
If a token response doens't have at least one of AccessToken or IdToken set then it's considered expired. If ExpiresInSeconds is null, the token is also considered expired.