Class TokenResponse (1.60.0)

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.

Inheritance

object > TokenResponse

Namespace

GoogleApisAuthOAuth2Responses

Assembly

Google.Apis.Auth.dll

Properties

AccessToken

public string AccessToken { get; set; }

Gets or sets the access token issued by the authorization server.

Property Value
Type Description
string

ExpiresInSeconds

public long? ExpiresInSeconds { get; set; }

Gets or sets the lifetime in seconds of the access token.

Property Value
Type Description
long

IdToken

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

Issued

[Obsolete("Use IssuedUtc instead")]
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

public DateTime IssuedUtc { get; set; }

The date and time that this token was issued, expressed in UTC.

Property Value
Type Description
DateTime
Remarks

This should be set by the CLIENT after the token was received from the server.

RefreshToken

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

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

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)

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

Extension Method