class OAuth2::Session


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

Defined in:



Instance Method Summary

Constructor Detail

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

Creates an OAuth2::Session.


  • 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.

Instance Method Detail

def access_token : AccessTokenSource

def authenticate(http_client)Source

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

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

def expires_at : Time?Source

def oauth2_client : ClientSource

© 2012–2020 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.