Skip to content

OAuth2Token

Troy Willmot edited this page Oct 21, 2016 · 1 revision

Summary

Represents a simple/base OAuth 2.0 token (bearer style token). Other types of token, such as MAC tokens, should derive from this class and provide additional properties for the extra values required. They should also override the SignRequest(HttpRequestMessage, OAuth2HttpRequestSigningMethod, string) method if neccesary, to correctly sign requests made with this token.

Properties

AccessToken

The access token value.

TokenType

The type of token this class represents.

ExpiresIn

The life time in seconds of this token.

Expiry

The calculated expiry date of the token. This value is based on the system clock. If the clients clock is incorrect, the calculated expiry will also be incorrect.

RefreshToken

An optional refresh token used to renew the access token after it expires.

Created

Sets or returns the date and time the token was created. This is automatically set to DateTime.Now by the constructor, but should be saved and reloaded along with the other properties if persisting the token between app sessions.

Methods

SignRequest(HttpRequestMessage request, OAuth2HttpRequestSigningMethod signingMethod, string tokenQueryKey)

Signs the specified HttpRequestMessage using this token. Unless overridden this method signs the request by setting providing the token value (and token type as the 'scheme' if signingMethod is OAuth2HttpRequestSigningMethod.AuthorizationHeader.

Clone this wiki locally