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.
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.
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).
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis document outlines the \u003ccode\u003eTokenResponse\u003c/code\u003e class, which represents a successful OAuth 2.0 access token response, as detailed in RFC6749, section 5.1.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTokenResponse\u003c/code\u003e class includes properties like \u003ccode\u003eAccessToken\u003c/code\u003e, \u003ccode\u003eExpiresInSeconds\u003c/code\u003e, \u003ccode\u003eIdToken\u003c/code\u003e, \u003ccode\u003eRefreshToken\u003c/code\u003e, and others to store essential token details.\u003c/p\u003e\n"],["\u003cp\u003eA crucial feature of the \u003ccode\u003eTokenResponse\u003c/code\u003e class is the \u003ccode\u003eIsStale\u003c/code\u003e property, indicating whether a token should be refreshed, even if it is still valid, and the \u003ccode\u003eIsExpired\u003c/code\u003e method to determine if a token has expired.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eFromHttpResponseAsync\u003c/code\u003e method allows for asynchronous parsing of a \u003ccode\u003eTokenResponse\u003c/code\u003e from an HTTP response, using provided clock and logger instances.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version available for the TokenResponse class is 1.69.0, with prior versions being listed down to 1.50.0.\u003c/p\u003e\n"]]],[],null,["# Class TokenResponse (1.69.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.69.0 (latest)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse)\n- [1.68.0](/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Auth.OAuth2.Responses.TokenResponse)\n- [1.60.0](/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Auth.OAuth2.Responses.TokenResponse)\n- [1.59.0](/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Auth.OAuth2.Responses.TokenResponse)\n- [1.55.0](/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Auth.OAuth2.Responses.TokenResponse)\n- [1.50.0](/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Auth.OAuth2.Responses.TokenResponse) \n\n public class TokenResponse\n\nOAuth 2.0 model for a successful access token response as specified in\n\u003chttp://tools.ietf.org/html/rfc6749#section-5.1\u003e. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e TokenResponse \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Apis.Auth.OAuth2.Responses](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses)\n\nAssembly\n--------\n\nGoogle.Apis.Auth.dll\n\nProperties\n----------\n\n### AccessToken\n\n [JsonProperty(\"access_token\")]\n public string AccessToken { get; set; }\n\nGets or sets the access token issued by the authorization server.\n\n### ExpiresInSeconds\n\n [JsonProperty(\"expires_in\")]\n public long? ExpiresInSeconds { get; set; }\n\nGets or sets the lifetime in seconds of the access token.\n\n### IdToken\n\n [JsonProperty(\"id_token\")]\n public string IdToken { get; set; }\n\nGets or sets the id_token, which is a JSON Web Token (JWT) as specified in \u003chttp://tools.ietf.org/html/draft-ietf-oauth-json-web-token\u003e\n\n### IsStale\n\n [JsonIgnore]\n public bool IsStale { get; }\n\nReturns true if the token represented by this token response should be refreshed.\nNote that this may be true for valid tokens, in which case a pre-emptive refresh is adviced\neven if the current token may be used while it continues to be valid.\n\n**Remarks** \nSee [MayBeUsed(IClock)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse#Google_Apis_Auth_OAuth2_Responses_TokenResponse_MayBeUsed_Google_Apis_Util_IClock_) for information on when a token is considered valid.\nA valid token is considered stale if it's close to expiring, but not so much as to be unusable.\n\n### Issued\n\n [Obsolete(\"Use IssuedUtc instead\")]\n [JsonProperty(Order = 1)]\n public DateTime Issued { get; set; }\n\nThe date and time that this token was issued, expressed in the system time zone.\nThis property only exists for backward compatibility; it can cause inappropriate behavior around\ntime zone transitions (e.g. daylight saving transitions).\n\n### IssuedUtc\n\n [JsonProperty(Order = 2)]\n public DateTime IssuedUtc { get; set; }\n\nThe date and time that this token was issued, expressed in UTC.\n\n**Remarks** \nThis should be set by the CLIENT after the token was received from the server.\n\n### RefreshToken\n\n [JsonProperty(\"refresh_token\")]\n public string RefreshToken { get; set; }\n\nGets or sets the refresh token which can be used to obtain a new access token.\nFor example, the value \"3600\" denotes that the access token will expire in one hour from the time the\nresponse was generated.\n\n### Scope\n\n [JsonProperty(\"scope\")]\n public string Scope { get; set; }\n\nGets or sets the scope of the access token as specified in \u003chttp://tools.ietf.org/html/rfc6749#section-3.3\u003e.\n\n### TokenType\n\n [JsonProperty(\"token_type\")]\n public string TokenType { get; set; }\n\nGets or sets the token type as specified in \u003chttp://tools.ietf.org/html/rfc6749#section-7.1\u003e.\n\nMethods\n-------\n\n### FromHttpResponseAsync(HttpResponseMessage, IClock, ILogger)\n\n public static Task\u003cTokenResponse\u003e FromHttpResponseAsync(HttpResponseMessage response, IClock clock, ILogger logger)\n\nAsynchronously parses a [TokenResponse](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse) instance from the specified [HttpResponseMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httpresponsemessage).\n\n### IsExpired(IClock)\n\n [Obsolete(\"Please use the TokenResponse.IsStale property instead.\")]\n public bool IsExpired(IClock clock)\n\nReturns true if the token is expired or it's going to expire soon.\n\n**Remarks** \nIf a token response doens't have at least one of [AccessToken](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse#Google_Apis_Auth_OAuth2_Responses_TokenResponse_AccessToken)\nor [IdToken](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse#Google_Apis_Auth_OAuth2_Responses_TokenResponse_IdToken) set then it's considered expired.\nIf [ExpiresInSeconds](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Auth.OAuth2.Responses.TokenResponse#Google_Apis_Auth_OAuth2_Responses_TokenResponse_ExpiresInSeconds) is null, the token is also considered expired.\n\nExtension Method\n----------------\n\n[Utilities.ThrowIfNull\\\u003cT\\\u003e(T, string)](/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)"]]