oauth2_fb_exchange_token_strategy

OAuth2 Strategy for Facebook Long-Lived User Access Tokens


Keywords
facebook, facebook-graph-api, facebook-graph-api-login, oauth2, oauth2-strategy, ruby
License
MIT
Install
gem install oauth2_fb_exchange_token_strategy -v 1.0.0

Documentation

OAuth2 Strategy for Facebook Long-Lived User Access Tokens

Gem Version Coverage Status Maintainability License: MIT

As per Facebook, default User and Page access tokens are short-lived, expiring in hours, however, you can exchange a short-lived token for a long-lived token.

This gem adds a new strategy to the excellent oauth2 gem that can be used to do just that.

Installation

gem install oauth2_fb_exchange_token_strategy

Or inside Gemfile

gem 'oauth2_fb_exchange_token_strategy'

Usage Examples

require 'oauth2'
require 'oauth2_fb_exchange_token_strategy'
client = OAuth2::Client.new('client_id', 'client_secret', site: 'https://graph.facebook.com/v9.0', authorize_url: 'https://www.facebook.com/v8.0/dialog/oauth', token_url: 'oauth/access_token')

short_lived_token = client.auth_code.get_token('authorization_code_value', redirect_uri: 'http://example.org/oauth2/callback')
token = client.fb_exchange_token(short_lived_token.token)
# => OAuth2::AccessToken