Skip to content

class OAuth2::Session
inherits Reference

An OAuth2 session makes it easy to implement APIs that need to refresh an access token once its expired before executing an HTTP request.

Class methods

.new(oauth2_client : Client, access_token : AccessToken, expires_at = Time.utc, &callback : OAuth2::Session -> )

Creates an OAuth2::Session.

Params: * oauth2_client: the OAuth2::Client used to refresh an access token. * access_token: the OAuth2::AccessToken to make requests. * expires_at: the Time when the access token expires. * callback: invoked when an access token is refreshed, giving you a chance to persist it.

View source

Methods

#access_token : AccessToken

View source

#authenticate(http_client)

Authenticates an HTTP::Client, refreshing the access token if it is expired.

Invoke this method on an HTTP::Client before executing an HTTP request.

View source

#expires_at : Time?

View source

#oauth2_client : Client

View source