datawookie/ubeR

ERROR: THE BASE REDIRECT URI DOES NOT MATCH THE REQUESTED REDIRECT

Closed this issue · 5 comments

Prior to running the code in folder ubeR/R/authorise.R, I authorized my app using my client_id/client_secret and the uber_oauth(UBER_CLIENTID, UBER_CLIENTSECRET, FALSE) function. Once I ran the OAuth2.0 code in the aforementioned file, I receive an error message every time I try to run the uber_oauth() function with my client id and secret: "ERROR: THE BASE REDIRECT URI DOES NOT MATCH THE REQUESTED REDIRECT". Is there a way to reset the base URI such that it matches my redirect URL? My ultimate goal is to make this public on a Shiny app, but for now my redirect url is the http://localhost:1410/.

Hi,

Can you send me your code (or an example which reproduces your problem) so that I can investigate?

Thanks, Andrew.

Originally when I was running this:

UBER_CLIENTID = "<my id>"
UBER_CLIENTSECRET = "<my secret>"

uber_oauth(UBER_CLIENTID, UBER_CLIENTSECRET, FALSE)

I received no errors, was redirected to the uber webpage where I put in my developer username/pswd. Was able to call all the ubeR functions. Then, I wanted to deploy my shiny app to shinyapps.io, so I thought to run this code in your documentation:

uber_oauth <- function(client_key, client_secret, cache = TRUE) {
  endpoint <- httr::oauth_endpoint(
    authorize = "https://login.uber.com/oauth/v2/authorize",
    access    = "https://login.uber.com/oauth/v2/token"
  )

  scope = c("profile", "history", "places", "request")
  token <- httr::oauth2.0_token(endpoint,
                                httr::oauth_app("uber", key = client_key, secret = client_secret),
                                scope = scope, cache = cache)

  assign("oauth_token", token, envir = auth_cache)
}

has_oauth_token <- function() {
  exists("oauth_token", envir = auth_cache)
}

get_oauth_token <- function() {
  if (!has_oauth_token()) {
    stop("This session doesn't yet have OAuth2.0 authentication.")
  }

  return(get("oauth_token", envir = auth_cache))
}

This ran with no error, but then upon running any ubeR functions, I received "is.response(x) is not TRUE" errors. Once I tried authenticating, I received the mismatch base URL/redirect error. I have tried many things such as changing cache=FALSE, inserting base_url = " http://localhost:1410/" in oauth_endpoint(), all to no avail.

@datawookie What is the code for the uber_oauth() function? i may have changed it which caused issues with the base URL.

@DeannaMo I'm somewhat confused by what you have done.

You say that you ran some code from my documentation... that code is actually part of the package. You do not need to run it manually. The function that you need for authentication, uber_oauth(), is already available once you load the ubeR package.

There is no need to run the large chunk of code in the last but one post. All of that is already in the package.

I suggest that you restart your R session, making sure that you are not picking up any residual data from any previous sessions (ie. check that there are no .RData files lying around).

This will at least give you a "clean" platform to work on.

Also, on reviewing your comments above, it appears that you are trying to manually run the code in the ubeR package. Please don't do this! Rather install the package (see the instructions here) and then load it using library(ubeR). You can find some usage instructions at the former link too.

Hope this helps, Andrew.

No further response on this issue, so I am going to assume that the problem was resolved.