1

I've come in such a circumstances where I need to pass authorization code without oauth login. User will be already login in salesforce and will be clicking on external link and that external server will be authenticated by using salesforce identity automatically.

Currently, when a hit is made to external server they redirect back to salesforce for OAuth2.0 and get the authorization code and after that they again make a request to get access token.

I just want to reduce one step to get authorization code by passing the code in URL parameter when first time we get redirected to external server. At that moment they will get Authorization code without making any extra call and will make only call to get access token.

So, my question is- is there any way to get authorization code that I can pass in external URL? Or do you know how it's generated?

I just tried to understand the pattern by observing the multiple codes generated through ouath and found that there is prefix which is always same in all codes like:

code 1: ayub.jdhajdbdkcbxncbnxcbzxcnbzhj==

Code 2: ayub.djbsjcbvdsjcvsbncvnbzcvbzcbcnzcvdcbc==

So, prefix ayub is same in each code but other remaining texts are different in each call.

I found one more question on developer forum but it's unanswered: https://developer.salesforce.com/forums/?id=906F0000000AxyYIAS

2

You can't programmatically generate the oauth token in Salesforce.

You have two options here:

  1. Use the username-password flow to get the token. Using then user don't need to verify again on screen. But this will be same for all users and also you might need a dummy user for this.

  2. Second you can use JWT token to authenticate the user and run the flow. I prefer this over the other.

OAuth 2.0 JWT Bearer Token Flow

  • 1
    Thanks for reply. 1st option would not work because each user has it's own login. 2nd one is good but involves a lot of steps to get JWT and will need to work again on development side....if there is no way to grab the authorization code then still I would prefer using OAUTH2.0 .... let's see if someone else has done kind of... – Ayub Apr 6 '18 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.