Skip to content

Error in token$sign : $ operator is invalid for atomic vectors #369

@msjgriffiths

Description

@msjgriffiths

This seems related to #208, but since it appears to be different I'm making a new issue.

I installed the dev version from Github, and the issue still occurs. Note that I also experienced #324 as my comment outlines. I have used that monkey patch to approach this point.

I'm trying to work through the Facebook demo. One of the lines is the GET request. The problem is that I receive an error.

# fb_app setup as in the demo: https://github.com/hadley/httr/blob/master/demo/oauth2-facebook.r#L10.
fb_token <- oauth2.0_token(oauth_endpoints("facebook"), fb_app, cache = F)
GET("https://graph.facebook.com/me", config(token = "fb_token"))
> Error in token$sign : $ operator is invalid for atomic vectors

The problem appears to be in the Token2.0 class. In brief, there's this line:

Authorization = paste('Bearer', self$credentials$access_token))

Unfortunately, for me, while I have a successful access token the fb_token$credentials, it looks like this:

> fb_token$credentials
[1] "access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&expires=5161857"

This is obviously not parsed out.

I can work around this issue by patching the $credentials value to have an $access_token value, i.e.

parsed_creds <- httr::parse_url(paste0("http://localhost/?", fb_token$credentials))
fb_token$credentials <- parsed_creds$query

req <- GET("https://graph.facebook.com/me", config(token = fb_token), verbose())

This completes fine, and returns the expected results.

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