OmniAuth
Last updated
Last updated
If you wish to use omniauth authentication, add all of your desired authentication provider gems to your Gemfile
.
OmniAuth example using GitHub, Facebook, Google, and Apple:
Then run bundle install
.
In config/initializers/omniauth.rb
, add the settings for each of your providers.
These settings must be obtained from the providers themselves.
Example using Github, Facebook, Google, and Apple:
The url for github authentication will be different for the client. The client should visit the API at /[MOUNT_PATH]/:provider
for omniauth authentication.
For example, given that the app is mounted using the following settings:
The client configuration for github should look like this:
Angular.js setting for authenticating using github:
jToker settings for github should look like this:
This incongruence is necessary to support multiple user classes and mounting points.
If you receive redirect-uri-mismatch
errors from your provider when using pow or xip.io urls, set the following in your development config:
The above example assumes that your provider keys and secrets are stored in environmental variables. Use the gem (or or or equivalent) to accomplish this.
The "Callback URL" setting that you set with your provider must correspond to the setting defined by this app. This will be different than the omniauth route that is used by your client application.
For example, the demo app uses the default omniauth_prefix
setting /omniauth
, so the "Authorization callback URL" for github must be set to "".
Github example for the demo site: