Class GoogleJsonWebSignature
Google JSON Web Signature as specified in https://developers.google.com/accounts/docs/OAuth2ServiceAccount.
Inherited Members
Namespace: Google.Apis.Auth
Assembly: Google.Apis.Auth.dll
Syntax
public class GoogleJsonWebSignature
Methods
ValidateAsync(string, ValidationSettings)
Validates a Google-issued Json Web Token (JWT).
Will throw a Invalid
Declaration
public static Task<GoogleJsonWebSignature.Payload> ValidateAsync(string jwt, GoogleJsonWebSignature.ValidationSettings validationSettings)
Parameters
Type | Name | Description |
---|---|---|
string | jwt | The JWT to validate. |
Google |
validationSettings | Specifies how to carry out the validation. |
Returns
Type | Description |
---|---|
Task<Google |
The payload of the verified token. |
Remarks
Follows the procedure to validate a JWT ID token.
Issued-at validation and expiry validation is performed using the clock on this local client,
so local clock inaccuracies can lead to incorrect validation results.
Use IssuedIssuedAtClockTolerance
defaults to 30 seconds; it is very unlikely a JWT will be issued that isn't already valid.
ExpirationTimeClockTolerance
defaults to zero seconds; in some use-cases it may be useful to set this to a negative
value to help ensure that passing local validation means it will pass server validation.
Regardless of whether local validation passed, code must always correctly handle an invalid JWT error
from the server.
Google certificates are cached, and refreshed once per hour. This can be overridden by setting
Force
Exceptions
Type | Condition |
---|---|
Invalid |
If the token does not pass verification. |
ValidateAsync(string, IClock, bool)
Validates a Google-issued Json Web Token (JWT).
Will throw a Invalid
Declaration
public static Task<GoogleJsonWebSignature.Payload> ValidateAsync(string jwt, IClock clock = null, bool forceGoogleCertRefresh = false)
Parameters
Type | Name | Description |
---|---|---|
string | jwt | The JWT to validate. |
IClock | clock | Optional. The Google. |
bool | forceGoogleCertRefresh | Optional. If true forces new certificates to be downloaded from Google. Defaults to false. |
Returns
Type | Description |
---|---|
Task<Google |
The JWT payload, if the JWT is valid. Throws an Invalid |
Remarks
Follows the procedure to validate a JWT ID token.
Google certificates are cached, and refreshed once per hour. This can be overridden by setting
forceGoogleCertRefresh
to true.
Exceptions
Type | Condition |
---|---|
Invalid |
Thrown when passed a JWT that is not a valid JWT signed by Google. |