We have implemented 2 OAuth flows between our app and SF where SF is auth provider – Web Server and Username and Password
Now we have use case where user is signed on SF and has to invoke our ASMX API.
Is it possible to write in SF APEX page – generate for me access token for current session and environment and to send that automatically (in message header) when I call our API ? If not what is the best approach, I would like still to keep SF as Oauth provider, do not want to provide/issue access tokens from my side in this communication.
Best Answer
Sometime back, I was trying to connect 2 saleforce org via Oauth/Rest API. I think I did something similar. On Salesforce org(Source) act as auth provider. I created connected app in Target org to finally get the Oauth Token. providing small code base for that:
Let me know in case you've any doubt over this :