Skip to content

dentarg/omniauth-auth0

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OmniAuth Auth0

This is the official OmniAuth strategy for authenticating to Auth0.

Installing

Add to your Gemfile:

gem 'omniauth-auth0'

Then bundle install.

Basic Usage

Rails

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :auth0, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'], ENV['YOUR_NAMESPACE']
end
```ruby

### Sinatra

```ruby
use OmniAuth::Builder do
  provider :auth0, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'], ENV['YOUR_NAMESPACE']
end

Optional you can set the :provider_ignores_state passing a fourth parameter. By default it is true.

Login widget

Integrate the widget in one of your pages as described here or use links as described in the same link.

Auth Hash

	{
	  :provider => 'auth0',
	  :uid => 'google-oauth2|this-is-the-google-id',
	  :info => {
	    :name => 'John Foo',
	    :email => '[email protected]',
	    :nickname => 'john',
	    :first_name => 'John',
	    :last_name => 'Foo',
	    :location => 'en',
	    :image => 'https://example.org/john.jpg'
	  },
	  :credentials => {
	    :token => 'XdDadllcas2134rdfdsI',
	    :expires => 'false',
	    :id_token => 'eyJhbGciOiJIUzI1NiIsImN0eSI6IkpXVCJ9.eyJuYW1lIjoiSm9obiBGb28ifQ.lxAiy1rqve8ZHQEQVehUlP1sommPHVJDhgPgFPnDosg',
	    :token_type => 'bearer',
	  },
	  :extra => {
	    :raw_info => {
	      :email => '[email protected]',
	      :email_verified => 'true',
	      :name => 'John Foo',
	      :given_name => 'John',
	      :family_name => 'Foo',
	      :picture => 'https://example.org/john.jpg',
	      :gender => 'male',
	      :locale => 'en',
	      :clientID => 'nUBkskdaYdsaxK2n9',
	      :user_id => 'google-oauth2|this-is-the-google-id',
	      :nickname => 'john',
	      :identities => [{
	        :access_token => 'this-is-the-google-access-token',
	        :provider => 'google-oauth2',
	        :expires_in => '3599',
	        :user_id => 'this-is-the-google-id',
	        :connection => 'google-oauth2',
	        :isSocial => 'true',
	      }],
	      :created_at: '2014-07-15T17:19:50.387Z'
	    }
	  }
	}

ActionDispatch::Cookies::CookieOverflow issue

If you are getting this error it means that you are using Cookie sessions and since you are storing the whole profile it overflows the max-size of 4K.

You can change to use In-Memory store for development as follows:

# /config/initializers/session_store.rb
CrazyApp::Application.config.session_store :cache_store

# /config/environments/development.rb
config.cache_store = :memory_store

Documentation

For more information about auth0 contact our documentation page.

License

MIT 2013 - AUTH0 INC.

About

Ruby client library for the Auth0 platform.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages