Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to sign in using LinkedIn #572

Closed
Quintasan opened this issue Mar 11, 2016 · 2 comments
Closed

Unable to sign in using LinkedIn #572

Quintasan opened this issue Mar 11, 2016 · 2 comments

Comments

@Quintasan
Copy link

I'm trying to sign in using LinkedIn by using decioferreira/omniauth-linkedin-oauth2 with devise_token_auth but can't get it to work. When signing in redirects me to the LinkedIn approval screen and then fails with

I, [2016-03-11T13:48:21.169962 #30087]  INFO -- omniauth: (linkedin) Callback phase initiated.
E, [2016-03-11T13:48:21.639795 #30087] ERROR -- omniauth: (linkedin) Authentication failure! invalid_credentials: OAuth2::Error, invalid_request: missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired
{"error_description":"missing required parameters, includes an invalid parameter value, parameter more than once. : Unable to retrieve access token : appId or redirect uri does not match authorization code or authorization code expired","error":"invalid_request"}
Processing by Devise::OmniauthCallbacksController#failure as HTML
  Parameters: {"resource_class"=>"User", "code"=>"[redacted]", "state"=>"[redacted]"}
Redirected to http://localhost:3000/auth/sign_in
Completed 302 Found in 47ms (ActiveRecord: 0.0ms)


Started GET "/auth/sign_in" for 127.0.0.1 at 2016-03-11 13:48:21 +0100
Processing by DeviseTokenAuth::SessionsController#new as HTML
Completed 405 Method Not Allowed in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)`

The application itself returns

{
  "errors": [
    "Use POST /sign_in to sign in. GET is not supported."
  ]
}

I have mounted devise_token_auth by adding mount_devise_token_auth_for 'User', at: 'auth' to config/routes.rb and added my application credentials to config/initializers/omniauth.rb

On a side note, is it possible to login to the Rails application using OAuth 2.0 token returned by LinkedIn (I want to login to my API using LinkedIn from my iOS device) or I am supposed to do it like outlined by Henrik Jachobsen?

@rccursach
Copy link

This is driving me nuts, i have the same issue, but i'm building an API in Rails for an Angular fronted, so i can't expose the APP_KEY and SECRET_KEY from the Linkedin OAuth API on client side js to get it done the way depicted in your link.

i've mounted the routes too and have my config into devise.rb initializer, with my tokens in the secrets.yaml passed form env vars, then i call:

config.omniauth :linkedin, Rails.application.secrets.linkedin_key, Rails.application.secrets.linkedin_secret

After log in from linkedin successfully i got:

{"errors":["Use POST /sign_in to sign in. GET is not supported."]}

Have you found a way to solve this?, i'm thinking into going from scratch without devise_token_auth, and using only ruby-jwt and omniauth by them selves.

For what i can guess, the redirection tries to show you the devise sign_in view/form to create the user, instead of creating a new one with post.
[POST] ...../sign_in #=> #create
[GET] ...../sign_in #=> #new

@zachfeldman
Copy link
Contributor

Hi there @Quintasan @rccursach ,

In an effort to cleanup this project and prioritize a bit, we're marking issues that haven't had any activity in a while with a "close-in-7-days" label. If we don't hear from you in about a week, we'll be closing this issue. Obviously feel free to re-open it at any time if it's the right time or this was done in error!

If you are still having the issue (especially if it's a bug report) please refer to our new Issue Template to provide some more details to help us solve it.

Hope all is well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants