Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sinsoku/oauth_adapter
https://github.com/sinsoku/oauth_adapter
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/sinsoku/oauth_adapter
- Owner: sinsoku
- License: mit
- Created: 2016-01-11T13:33:55.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-17T03:43:42.000Z (over 8 years ago)
- Last Synced: 2024-04-26T01:20:41.261Z (8 months ago)
- Language: Ruby
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# OAuthAdapter
[![Gem Version](https://badge.fury.io/rb/oauth_adapter.svg)](https://badge.fury.io/rb/oauth_adapter)
[![Build Status](https://travis-ci.org/sinsoku/oauth_adapter.svg?branch=master)](https://travis-ci.org/sinsoku/oauth_adapter)
[![codecov](https://codecov.io/gh/sinsoku/oauth_adapter/branch/master/graph/badge.svg)](https://codecov.io/gh/sinsoku/oauth_adapter)It provides a simple method to use the OAuth libraries.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'oauth_adapter'
```And then execute:
$ bundle
## Configuration
```ruby
OAuthAdapter.configure do
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET'], 'https://api.twitter.com'
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], 'https://api.github.com'
end
```### OmniAuth Support
If you use with [intridea/omniauth](https://github.com/intridea/omniauth), you may omit the configuration by requiring 'oauth_adapter/omniauth'. This is an example at `config/initializers/omniauth.rb`:
```ruby
require 'oauth_adapter/omniauth'Rails.application.config.middleware.use OmniAuth::Builder do
provider :developer unless Rails.env.production?
provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET']
end
```## Usage
You will get either appropriate object of OAuth or OAuth2.
```ruby
OAuthAdapter.get_access_token(provider: :github, token: '')
#=> #', secret: '')
#=> #