8
votes

I am using this code with my client ID and client secret:

https://github.com/DEKHTIARJonathan/python3-linkedin/blob/master/examples/oauth2_authentication.py

However, when getting the url back in the command line and putting it into the browser I am getting "invalid redirect_uri. This value must match a URL registered with the API Key."

I've registered the following with redirect urls in an attempt to get it working:

http://localhost:8080/code
https://localhost:8080/code/
http://localhost:8080/code/signin-linkedin
https://localhost:8080/code/signin-linkedin
https%3A//locahost%3A8080/code/

The signin-linkedin piece came from here:

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

However, adding that last 'sigin-linkedin' portion didn't alleviate the issue.

This is the URL that I am getting back, # in place of my client_id:

https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=##########&scope=r_basicprofile%20r_emailaddress%20rw_company_admin%20w_share&state=04377850f3154ee3f808f762244697b6&redirect_uri=https%3A//locahost%3A8080/code/

Thanks in advance.

Edit:

I've tried adding some additional urls based on other posts:

https://appname.auth0.com/login/callback

https://appname.auth0.com

Here is my code:

if __name__ == '__main__':

    CLIENT_ID = #######
    CLIENT_SECRET = ##########
    RETURN_URL = 'http://localhost:8080/code/'

    authentication = LinkedInAuthentication(
                    CLIENT_ID,
                    CLIENT_SECRET,
                    RETURN_URL,
                    permissions=['r_basicprofile',
                                 'r_emailaddress',
                                 'rw_company_admin',
                                 'w_share']
                )

    print(authentication.authorization_url)
    application = LinkedInApplication(authentication)
2

2 Answers

3
votes

It looks like your callback URL configuration has a mistake, a missing "l".

If you look closely at the redirect_uri parameter, its value is https%3A//locahost%3A8080/code/ which unescaped is https://locahost:8080/code/.

I assume you mean the value to be configured as https://localhost:8080/code/.

1
votes

Your URL encoding of the redirect_uri looks incorrect.

For me, http://localhost:8080/code/ turns into http%3A%2F%2Flocalhost%3A8080%2Fcode%2F.

You are sending "/" when it should be "%2F".