Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fdeschenes/oauth2-fb-exchange-token-strategy
OAuth2 Strategy for Facebook Long-Lived User Access Tokens
https://github.com/fdeschenes/oauth2-fb-exchange-token-strategy
facebook facebook-graph-api facebook-graph-api-login oauth2 oauth2-strategy ruby
Last synced: 16 days ago
JSON representation
OAuth2 Strategy for Facebook Long-Lived User Access Tokens
- Host: GitHub
- URL: https://github.com/fdeschenes/oauth2-fb-exchange-token-strategy
- Owner: fdeschenes
- License: mit
- Created: 2020-11-14T14:19:39.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T00:37:31.000Z (8 months ago)
- Last Synced: 2024-10-10T09:18:10.715Z (28 days ago)
- Topics: facebook, facebook-graph-api, facebook-graph-api-login, oauth2, oauth2-strategy, ruby
- Language: Ruby
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# OAuth2 Strategy for Facebook Long-Lived User Access Tokens
[![Gem Version](https://badge.fury.io/rb/oauth2_fb_exchange_token_strategy.svg)](https://badge.fury.io/rb/oauth2_fb_exchange_token_strategy)
[![Coverage Status](https://coveralls.io/repos/github/fdeschenes/oauth2-fb-exchange-token-strategy/badge.svg?branch=master)](https://coveralls.io/github/fdeschenes/oauth2-fb-exchange-token-strategy?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/34355bd39e55a168918a/maintainability)](https://codeclimate.com/github/fdeschenes/oauth2-fb-exchange-token-strategy/maintainability)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/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](https://developers.facebook.com/docs/facebook-login/access-tokens/refreshing/).
This gem adds a new strategy to the excellent [oauth2](https://github.com/oauth-xx/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
```ruby
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.get_token(short_lived_token.token)
# => OAuth2::AccessToken
```