linkedin : Invalid redirect_uri. This value must match a URL registered with the API Key

55,925

Solution 1

Went back to LinkedIn developer site (https://www.linkedin.com/secure/developer ) to check my setting again. Everything matches API Key, Secret Key and OAuth 2.0 Redirect URLs.

Searched web looking for some clues. Couldn’t find a one.
Crazy issue:

Then I saw that in the URL Owin was appending some extra string to the redirect_uri “signin-linkedin”.
When I decoded the URL I saw this http://localhost:54307/signin-linkedin .
I took this URL and placed it in the OAuth 2.0 Redirect URLs field in the LinkedIn developer site.

This link is helpful for me
https://naveengopisetty.wordpress.com/2014/09/15/linkedin-oauth-2-0-issue-invalid-redirect_uri-this-value-must-match-a-url-registered-with-the-api-key/

Solution 2

please check your redirect_url. for my case I see like this.

https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=77k93y0w31zaey&redirect_uri=http%3A%2F%2Flocalhost%3A1729%2Fsignin-linkedin&scope=r_basicprofile%2Cr_emailaddress&state=nhAC-nR-CgEwO3XS2ezANhuPBMz-IUmLPJYgGHlZvZ8B1pCfsGBU0PR0dZ5XxE4zbyeI0RLcKByqPLKkgQdqMm4s6DjFYqMCEehYA2iWT9MfioEHjPXGCt2USxUTF0wKBpflCUjG5URVlJa3qI7U3ydFOErZ4Hhnr9SVmKdf1bithYfbOqBx345o8LQLexbddQ687vP6y0szrIyCM6FHip1tCpOY3Hgg5FJQEFH1mCJ_yLunD5vDUN4VVfkQbcjk

for this I add the url for OAuth 2.0 Authorized Redirect URLs:

http://localhost:1729/signin-linkedin

where http://localhost:1729 =base url and
signin-linkedin = the string which add after base url

Solution 3

You can just look in url that you are getting that error message on.

eg. if you are using python's social auth the url would look like this:

https://www.linkedin.com/uas/oauth2/authorization?scope=r_basicprofile+r_emailaddress&state=XXXXXX&redirect_uri=http://example.com.au/sa/complete/linkedin-oauth2/&response_type=code&client_id=YYYYYYY

so you would use this part of the above url for the redirect url

http://example.com/sa/complete/linkedin-oauth2/

Solution 4

One more solution is to just verify the client_id you've been using the whole time..because with every update in the list of redirect_uri, the client_id gets updated.

Share:
55,925

Related videos on Youtube

Dipak Panchal
Author by

Dipak Panchal

Front-end & Back-end developer having 9+ years of experience. 20+ successful projects | 5 stars for all completed projects in up-work SOME HIGHLIGHTS → Happy client all over the world → 100% client satisfaction → Best Customer support → 20+ successful projects → 10 - 30 days free bug support after completion of the project. EXPERTISE → My Back-end Skills REST Ruby On Rails → My Front-end Skills HTML5 & CSS3 twitter bootstrap AngularJS JavaScript JQuery → UX Design Wire-framing → Third party services and libraries Clouds: AWS EC2, Lambda, S3, Digital Ocean, Heroku Payment Gateway: PayPal, Stripe, Authorize.net Google Map API / Google Place API Chart libraries: D3js, highchart → Version control system git GitHub → Project tracking systems Slack Atlassian JIRA Trello → AWS AWS RDS PostgreSQL AWS API Gateway AWS Lambda Amazon S3 Amazon SQS Amazon SES Amazon EC2 Amazon Route52 → Database MySQL PostgreSQL We are ready to develop a long-term business relationship for any kind of web development needs. Our main goal is to satisfy our clients with the best quality work in accurate time.

Updated on July 09, 2022

Comments

  • Dipak Panchal
    Dipak Panchal almost 2 years

    I am using 'omniauth-linkedin-oauth2'.

    When I am login with linkedin then I am getting this error

    Invalid redirect_uri. This value must match a URL registered with the API Key.

    This is my settings:

    Screenshot

    • Nithin
      Nithin over 9 years
      Api key and value, set properly?
    • Nithin
      Nithin over 9 years
      title says twitter?
    • Ilya Bodrov-Krukowski
      Ilya Bodrov-Krukowski over 9 years
      Redirect URL should probably be http://localhost:3000/auth/linkedin/callback - this is how OmniAuth strategies work. Then you should open up your site as http://localhost:3000 and try to authenticate.
    • Taimoor Changaiz
      Taimoor Changaiz about 9 years
      @bodrovis bro saved my time :). But incase of facebook gem 'omniauth-facebook' redirect_uri localhost:3000 is working fine.
    • Alan Dong
      Alan Dong about 8 years
    • Lodewijck
      Lodewijck about 8 years
      Solution in my case: press update after adding the URLs :)
    • GrvTyagi
      GrvTyagi over 7 years
      hello @Dipak Panchal time to choose an ans ;)
  • zinczinc
    zinczinc over 7 years
    Adding "signin-linkedin" at the end of the uri like this: example.com/signin-linkedin worked for me!
  • Prasanna
    Prasanna over 5 years
    i resolved that error, but can you tell me how to open that login screen inside browser instead of opening in network tab? i'm facing very strange problem, screen is being opening in network tab instead of opening in browser
  • Dr. MAF
    Dr. MAF over 4 years
    Excellent. Thanks.
  • adi_tdkr
    adi_tdkr about 2 years
    Thanks worked for me. Whenever you change redirect_uri clientid changes so don't forget to copy new client id. Thanks for helping