Search code examples
rapioauth-2.0linkedin-apihttr

LinkedIn API error of redirect uri from httr


I'm trying to access LinkedIn's API using R and the httr package.

When I execute the last oauth2.0_token() function, in order to gain an authorization token, I get the following error from LinkedIn: "The redirect_uri does not match the registered value".

I've set my redirected url on the LinkedIn Developer site to http://my_app_54321

Does anyone know what the solution is?

# Packages
library(httr)

# Client info
clientid <- "my_id"
secret <- "my_secret"

# App
app <- oauth_app(appname = "app name", key = clientid, secret = secret)

# Endpoints
endpoint <- oauth_endpoint(base_url = "https://www.linkedin.com/uas/oauth2", 
                           authorize = "authorization", access = "accessToken")

# Access token
token <- oauth2.0_token(endpoint = endpoint, app = app)
token

LinkedIn error message


Solution

  • Changing my redirected url to the following solved it since I just needed the application to run locally.

    http://localhost:1410/
    

    The comments from the GitHub of httr package pointed in this direction:

    https://github.com/r-lib/httr/blob/master/demo/oauth2-linkedin.r