Class TokenResponse
OAuth 2.0 model for a successful access token response as specified in http://tools.ietf.org/html/rfc6749#section-5.1.
Inheritance
Inherited Members
Namespace: Google.Apis.Auth.OAuth2.Responses
Assembly: Google.Apis.Auth.dll
Syntax
public class TokenResponse
Properties
AccessToken
Gets or sets the access token issued by the authorization server.
Declaration
[JsonProperty("access_token")]
public string AccessToken { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ExpiresInSeconds
Gets or sets the lifetime in seconds of the access token.
Declaration
[JsonProperty("expires_in")]
public long? ExpiresInSeconds { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Int64> |
IdToken
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
Declaration
[JsonProperty("id_token")]
public string IdToken { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Issued
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).
Declaration
[Obsolete("Use IssuedUtc instead")]
[JsonProperty(Order = 1)]
public DateTime Issued { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
IssuedUtc
The date and time that this token was issued, expressed in UTC.
Declaration
[JsonProperty(Order = 2)]
public DateTime IssuedUtc { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime |
Remarks
This should be set by the CLIENT after the token was received from the server.
RefreshToken
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.
Declaration
[JsonProperty("refresh_token")]
public string RefreshToken { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Scope
Gets or sets the scope of the access token as specified in http://tools.ietf.org/html/rfc6749#section-3.3.
Declaration
[JsonProperty("scope")]
public string Scope { get; set; }
Property Value
Type | Description |
---|---|
System.String |
TokenType
Gets or sets the token type as specified in http://tools.ietf.org/html/rfc6749#section-7.1.
Declaration
[JsonProperty("token_type")]
public string TokenType { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
FromHttpResponseAsync(HttpResponseMessage, IClock, ILogger)
Asynchronously parses a TokenResponse instance from the specified System.Net.Http.HttpResponseMessage.
Declaration
public static Task<TokenResponse> FromHttpResponseAsync(HttpResponseMessage response, IClock clock, ILogger logger)
Parameters
Type | Name | Description |
---|---|---|
System.Net.Http.HttpResponseMessage | response | The http response from which to parse the token. |
Google.Apis.Util.IClock | clock | The clock used to set the Issued value of the token. |
Google.Apis.Logging.ILogger | logger | The logger used to output messages incase of error. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TokenResponse> | A task containing the TokenResponse parsed form the response message. |
Exceptions
Type | Condition |
---|---|
TokenResponseException | The response was not successful or there is an error parsing the response into valid TokenResponse instance. |
IsExpired(IClock)
Returns true
if the token is expired or it's going expire soon.
Declaration
public bool IsExpired(IClock clock)
Parameters
Type | Name | Description |
---|---|---|
Google.Apis.Util.IClock | clock |
Returns
Type | Description |
---|---|
System.Boolean |