Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

tkn gives null variable #61

Closed
dkomd opened this issue Jun 14, 2017 · 2 comments
Closed

tkn gives null variable #61

dkomd opened this issue Jun 14, 2017 · 2 comments

Comments

@dkomd
Copy link

dkomd commented Jun 14, 2017

Hello

Does anybody else have an issue with this code line:
tkn <- tkn$credentials$access_token producing "null" instead of token because access_token variable has become part of the name of the list?
This is what I mean below


 tkn$credentials$access_token
NULL
> names(tkn$credentials)
[1] "{\"access_token\":\"SOME TOKEN",\"token_type\":\"bearer\"}"
> fromJSON(names(tkn$credentials))
$access_token
[1] "SOME TOKEN"

$token_type
[1] "bearer"

> new_tkn <- fromJSON(names(tkn$credentials))
> new_tkn$access_token
[1] "SOME TOKEN"

So, the only way to access the token is access the name of the list and convert it to a JSON format after which you can access the access_token
I've used fbRads code with the tkn$credentials$access_token part last year and it worked fine; however, this year the same line was not working for me. I looked over github intro page and the original code does not seem to have changed, so just curious whether this is an issue just with my computer.

@daroczig
Copy link
Owner

Yeah, I'm not sure if it's a change in httr or at Facebook, but currently the below full example works:

library(httr)
app <- oauth_app('facebook', '***', '***')
tkn <- oauth2.0_token(
    oauth_endpoints('facebook'), app, scope = 'business_management',
    type  = 'application/x-www-form-urlencoded', cache = FALSE)
tkn <- jsonlite::fromJSON(names(tkn$credentials))$access_token

@daroczig
Copy link
Owner

As per above commit, I'm closing this -- please reopen the update doesn't work as expected. Thanks again for the report!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants