Hello,
I have a very specific use case where I’m trying to implement Oauth2 against a Salesforce (SFDC) instance. I’ve been stuck at this point for a while now where I can get past the login prompt but no token is returned. I’m using this piece of documentation as a guideline: https://help.salesforce.com/articleView?id=remoteaccess_oauth_web_server_flow.htm&type=5
This is a break down of what I’ve done:
- Call back url is declared in SFDC, as well as all of the scopes (I have access to all of them).
- Passing scopes is required in order to get a refresh token - it took a lot of research to find this out since it’s not well documented. However, SFDC requires the tokens to be separated by %20, and not the standard +. I followed this guidance from @patrick to achieve the same.
- I have an Oauth2 instance declared in the Globals panel:
and my SalesForce admin says he successfully uses the same parameters from Postman (which I have no experience of). - I have an authorize instance in my PHP server side action:
When I try to run the code, I am prompted to login to SalesForce if I wasn’t previously (this is expected) and to authorize the app to do a number of actions on my behalf, and then the worflow breaks with this error:
{"code":0,"file":"\/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/oauth\/Oauth2.php","line":266,"message":"Http response has no access_token","trace":"#0 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/oauth\/Oauth2.php(230): lib\\oauth\\Oauth2->grant('authorization_c...', Array)\n#1 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/modules\/oauth.php(24): lib\\oauth\\Oauth2->authorize(Array, Object(stdClass))\n#2 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/App.php(193): modules\\oauth->authorize(Object(stdClass), 'sfdc_credential...')\n#3 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/App.php(157): lib\\App->execSteps(Object(stdClass))\n#4 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/App.php(127): lib\\App->execSteps(Array)\n#5 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/App.php(116): lib\\App->exec(Object(stdClass), false)\n#6 \/home\/vcap\/app\/htdocs\/dmxConnectLib\/lib\/App.php(94): lib\\App->exec(Object(stdClass))\n#7 \/home\/vcap\/app\/htdocs\/dmxConnect\/api\/Escalations\/escalation_closure.php(8): lib\\App->define(Object(stdClass))\n#8 {main}"}
What is of interest seems to be: :"Http response has no access_token"
.
My only idea was that maybe the ‘code’ parameter needed to be passed on or declared from either the Oauth2 or Authorize steps, which I have tried one after the, simultaneously, and one without the other - it has not changed anything, I get the exact same behavior. The way I did this was by declaring a $_GET input for ‘code’:
And then referencing it where it could have made sense to me:
- in the Oauth2 instance:
-in the Authorize instance:
At this point I have exhausted my thin knowlegde and my ideas, I would appreciate any suggestions.
Thanks!
Nahtaniel.
Last updated: