Closed carlganz closed 3 years ago
@carlganz Did you try assigning the output of sf_auth()
to a variable and using that? For example, deleting your cached .httr-oauth-salesforcer
file and running:
auth_data <- sf_auth()
token <- auth_data$token
access_token <- token$credentials$access_token
This should work because the sf_auth()
function invisibly returns some things that might be helpful to you:
The sf_access_token()
will return null if you are using Basic Authentication (Username, Password, and Security Key)
I did not!
I would strongly encourage you to add some documentation about the return value.
@carlganz Were you using basic authentication and that's why it returned NULL
and was confusing or was it something wrong with how sf_access_token()
works? Just curious if it's a bug, or I just need to highlight the usage better? Thanks!
I was using basic auth and didn't realize that session id
is the Bearer token I need so I guess it's my own misunderstanding of Salesforce authentication. At the very least I would suggest documenting that sf_auth
returns auth info and at best I would document meaning of each value returned.
As always, thanks for building and supporting this exceptionally useful package!
Issue submission checklist
When filing your issue please make an attempt to troubleshoot a little bit on your own. If your issue is specifically related to a query, but please consider using the "Query issue template". Also, please consider some of the suggestions below before submitting an issue. Thank you!
[X] I have set
verbose=TRUE
function argument if possible.[X] I have tried a few different function call arguments to see if I can workaround and/or isolate the issue (e.g. reviewing the output from the "SOAP" vs "REST" or the "Bulk 1.0" vs "Bulk 2.0" or tinkering with the
control
argument in the function call).[X] I have taken a look at the unit tests directory ./tests/testthat/ to see if my type of issue has been documented and tested.
[X] I have considered making a minimal reproducible example using the reprex package. Details on how to create a reprex are available here: https://www.tidyverse.org/help/#reprex.
[X] I have included the version of R and any packages that are used (Hint: Simply copy/paste the result of
devtools::session_info()
at the bottom of your issue).Thank you for considering these steps. It will speed up the process of resolving your issue.
Issue description
I am using R to interact with some custom RestResources I've developed, and would like to extract the access token from my existing
salesforcer
session.The
sf_access_token()
function sounds like what I want but returns null and documentation seems to indicate I shouldn't use this.The docs for
sf_auth
here seem to indicate there is some way to access the token but thesalesforcer_state()
object in the example isn't defined in the example so I don't know how to recreate myselfreprex
Session Info