Salesforce OAuth Example
Salesforce has some special requirements:
| • | When logging for an authorization code, Salesforce always sends email to a registered email box with a verification code, and asks for this code during the process. You need to handle this manually or use CustomFlow. |
| • | Check Use Refresh Token To Get Access Token after obtaining the access_token and refresh_token the first time. If you do this, the token can be retrieved automatically each time, without needing to check the verification code manually in the email box. |
In the example, using the JavaScript regular expression to fetch the authorization code is just for demonstration purposes.
|
OAuth Tab Field |
Example Values |
|
Authorization URI |
https://login.salesforce.com/services/oauth2/authorize |
|
AccessToken URI |
https://login.salesforce.com/services/oauth2/token |
|
Text field below the Using Processors check box
|
<Authorization> <ResponseMsgStyle>RAWBODY</ResponseMsgStyle> <AuthorizationProcessors> <AuthorizationProcessor> document.getElementById('username').value='test@gmail.com'; document.getElementById('password').value='xxxxxx'; document.getElementById('Login').click();</AuthorizationProcessor> </AuthorizationProcessors> <TokenProcessor> var pattern=/\?code=.+'/i; var ans = pattern.exec(MessageValue); if(ans.index>0){MessageValue = "{code:" + ans[0].substring(6,ans[0].length-1)+"}";}</TokenProcessor> </Authorization> |