OAuth2::Session

class OAuth2::Session

Overview

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:

oauth2/session.cr

Class Method Summary

Instance Method Summary

Class Method Detail

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

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.

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–2017 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/0.22.0/OAuth2/Session.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部