Class TokenResponse (1.55.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

Google.Apis.Auth.OAuth2.Responses

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
TypeDescription
String

ExpiresInSeconds

public long? ExpiresInSeconds { get; set; }

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

Property Value
TypeDescription
Nullable<Int64>

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
TypeDescription
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
TypeDescription
DateTime

IssuedUtc

public DateTime IssuedUtc { get; set; }

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

Property Value
TypeDescription
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
TypeDescription
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
TypeDescription
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
TypeDescription
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
NameDescription
responseHttpResponseMessage

The http response from which to parse the token.

clockIClock

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

loggerILogger

The logger used to output messages incase of error.

Returns
TypeDescription
Task<TokenResponse>

A task containing the TokenResponse parsed form the response message.

Exceptions
TypeDescription
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
NameDescription
clockIClock
Returns
TypeDescription
Boolean
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