The above example assumes that your provider keys and secrets are stored in environmental variables. Use the figaro gem (or dotenv or secrets.yml or equivalent) to accomplish this.
OmniAuth callback settings
The "Callback URL" setting that you set with your provider must correspond to the omniauth prefix setting defined by this app. This will be different than the omniauth route that is used by your client application.
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.
angular.module('myApp', ['ng-token-auth'])
.config(function($authProvider) {
$authProvider.configure({
apiUrl: 'https://api.example.com'
authProviderPaths: {
github: '/auth/github' // <-- note that this is different than what was set with github
}
});
});
$.auth.configure({
apiUrl: 'https://api.example.com',
authProviderPaths: {
github: '/auth/github' // <-- note that this is different than what was set with github
}
});
# config/environments/development.rb
# when using pow
OmniAuth.config.full_host = "http://app-name.dev"
# when using xip.io
OmniAuth.config.full_host = "http://xxx.xxx.xxx.app-name.xip.io"