Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sinsoku/oauth_adapter


https://github.com/sinsoku/oauth_adapter

Last synced: about 1 month ago
JSON representation

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: '')
#=> #