项目作者: fdeschenes

项目描述 :
OAuth2 Strategy for Facebook Long-Lived User Access Tokens
高级语言: Ruby
项目地址: git://github.com/fdeschenes/oauth2-fb-exchange-token-strategy.git
创建时间: 2020-11-14T14:19:39Z
项目社区:https://github.com/fdeschenes/oauth2-fb-exchange-token-strategy

开源协议:MIT License

下载


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

  1. gem install oauth2_fb_exchange_token_strategy

Or inside Gemfile

  1. gem 'oauth2_fb_exchange_token_strategy'

Usage Examples

  1. require 'oauth2'
  2. require 'oauth2_fb_exchange_token_strategy'
  3. 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')
  4. short_lived_token = client.auth_code.get_token('authorization_code_value', redirect_uri: 'http://example.org/oauth2/callback')
  5. token = client.fb_exchange_token.get_token(short_lived_token.token)
  6. # => OAuth2::AccessToken