module OAuth2


The OAuth module provides an OAuth2::Client as specified by RFC6749.

Performing HTTP client requests with OAuth2 authentication

Assuming you have an access token, you can setup an HTTP::Client to be authenticated with OAuth2 using this code:

require "http/client"
require "oauth2"

# Here we use a bearer token, but it could be a mac token
access_token ="some_access_token")

# Create an HTTP::Client
client ="", tls: true)

# Prepare it for using OAuth2 authentication

# Execute requests as usual: they will be authenticated

This is implemented with HTTP::Client#before_request to add an authorization header to every request.

Obtaining access tokens

See OAuth2::Client for an example.

Defined in: