Show / Hide Table of Contents

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
object
TokenResponse
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
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
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
long?

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
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
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
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
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
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
string

Methods

FromHttpResponseAsync(HttpResponseMessage, IClock, ILogger)

Asynchronously parses a TokenResponse instance from the specified HttpResponseMessage.

Declaration
public static Task<TokenResponse> FromHttpResponseAsync(HttpResponseMessage response, IClock clock, ILogger logger)
Parameters
Type Name Description
HttpResponseMessage response

The http response from which to parse the token.

IClock clock

The clock used to set the Issued value of the token.

ILogger logger

The logger used to output messages incase of error.

Returns
Type Description
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 to expire soon.

Declaration
public bool IsExpired(IClock clock)
Parameters
Type Name Description
IClock clock
Returns
Type Description
bool
Remarks

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.

In This Article
Back to top Generated by DocFX