Skip to content

oauth_service_token Not working with scope as list/vector of urls, only as space delimited string #282

Closed
@thomascjohnson

Description

@thomascjohnson

Distinct possibility that I'm doing something completely wrong, but I can't seem to get this function to work. I believe in the past I have coded out the http request myself to get it to function. Here is some example code:

httr::oauth_service_token(httr::oauth_endpoints("google"),
                          jsonlite::fromJSON("mycredentials.json"),
                          c("https://www.googleapis.com/auth/drive",         
                            "https://www.googleapis.com/auth/drive.metadata"))

And from this I get:

Error in init_oauth_service_account(self$endpoint, self$secrets, self$params$scope) : 
  client error: (400) Bad Request

However, this works:

httr::oauth_service_token(httr::oauth_endpoints("google"),
                          jsonlite::fromJSON("mycredentials.json"),
                          "https://www.googleapis.com/auth/drive")

and so does this:

httr::oauth_service_token(httr::oauth_endpoints("google"),
                          jsonlite::fromJSON("mycredentials.json"),
                          paste(c("https://www.googleapis.com/auth/drive",         
                                  "https://www.googleapis.com/auth/drive.metadata"),
                                collapse = " "))

It looks like it all comes down to needing to supply the scopes as a space delimited string (just like the Google API wants – keep in mind it may be different for different APIs). I am putting this here for posterity so should anyone else run into the problem, they have a solution. I will try to find the problem in the package itself and send a pull request – that is, if this isn't a planned "feature" in the first place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions