I have been using Salesforce integration with Verj IO using REST to read information in our Salesforce instance and use it in Verj IO.
According to this page https://developer.salesforce.com/docs/a ... cation.htm, there are 3 different ways to authenticate using OAuth:
1. Web server flow
2. User-agent flow
3. Username-password flow
The first 2 methods require a https based URL as a callback URL that is called after the user authenticates which provides the access token. Since my VerjIO instance is not publicly accessible, I don't think that the first 2 methods will work for me since I don't have a publicly accessible callback URL to provide to the endpoint.
I currently have a REST Web Service Resource that I created which uses the 3rd method and this works fine.
The web service resource is configured like this:
Endpoint URL: https://login.salesforce.com/services/oauth2/token
Method: POST
Query parameters
----------------------
grant_type: password
client_id: <my client id>
client_secret: <my client secret>
username: <my username>
password: <my password appended with my security token>
Request Headers:
Content-Type: application/x-www-form-urlencoded
This works great but I only have 1 issue with this set up. Every so often, Salesforce requires you to change your password which also generates a new security token. When this happens, I have to remember to go into the web service resource and change the password and security token.
This isn't a huge deal but its annoying to have to do because I don't like the idea of updating the service every so often.
Is anyone else here who is using Salesforce able to suggest a better approach that will overcome this issue ?
Connecting to Salesforce using OAuth
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
-
- Moderator
- Posts: 414
- Joined: Fri Sep 07, 2007 3:44 pm
- Location: Sandy, UK
- Contact:
Re: Connecting to Salesforce using OAuth
Hi Segi,
I have not used Sales Force, but from reading their documentation the Username-password flow does not support refresh tokens. So it looks as though you do not have any choice, but to refresh the web service when required.
Kind regards
Steve
I have not used Sales Force, but from reading their documentation the Username-password flow does not support refresh tokens. So it looks as though you do not have any choice, but to refresh the web service when required.
Kind regards
Steve
0 x
-
- Moderator
- Posts: 414
- Joined: Fri Sep 07, 2007 3:44 pm
- Location: Sandy, UK
- Contact:
Re: Connecting to Salesforce using OAuth
Hi Segi,
It dawned on me that I think it is the browser that forwards the URL. I know with spotify I used a http://localhost:3030/..... callback url when I have tested the Spotify using User Flow and this works fine.
Have you tried the user-agent flow using Ebase OAuth authentication with a callback URL of something like?
http://localhost:3030/ebase/ufsreturn
Kind regards
Steve Upton
It dawned on me that I think it is the browser that forwards the URL. I know with spotify I used a http://localhost:3030/..... callback url when I have tested the Spotify using User Flow and this works fine.
Have you tried the user-agent flow using Ebase OAuth authentication with a callback URL of something like?
http://localhost:3030/ebase/ufsreturn
Kind regards
Steve Upton
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Re: Connecting to Salesforce using OAuth
Steve,
I don't think that that will work since the callback URL is called after you gave tried logging in and returns a JSON payload that includes an access_token after you have successfully authenticated.
As I mentioned, my server is not publicly accessible and using a URL with localhost:3030/ebase/whatever would not work because Salesforce needs to reach that callback URL to provide the JSON payload
I don't think that that will work since the callback URL is called after you gave tried logging in and returns a JSON payload that includes an access_token after you have successfully authenticated.
As I mentioned, my server is not publicly accessible and using a URL with localhost:3030/ebase/whatever would not work because Salesforce needs to reach that callback URL to provide the JSON payload
0 x
-
- Moderator
- Posts: 414
- Joined: Fri Sep 07, 2007 3:44 pm
- Location: Sandy, UK
- Contact:
Re: Connecting to Salesforce using OAuth
Thanks Segi,
I have tested this with other OAuth2 connectors before (Spotify and Google) and used the callback URL of http://localhost.... and this works because the "browser" does the forwarding... not the server. So I am not sure whether this would be different?
According to the Salesforce documentation from:
https://help.salesforce.com/articleView ... erview.htm
The callback URL is an endpoint in your application to which Salesforce can redirect the user’s browser with an authentication code or access token.
But this may only work with in a test scenario... I also noticed that it had to be https:// so you would need to put in the https://<name-of-server>/ebase/ufsreturn
Anyway... might be worth a try?
Steve
I have tested this with other OAuth2 connectors before (Spotify and Google) and used the callback URL of http://localhost.... and this works because the "browser" does the forwarding... not the server. So I am not sure whether this would be different?
According to the Salesforce documentation from:
https://help.salesforce.com/articleView ... erview.htm
The callback URL is an endpoint in your application to which Salesforce can redirect the user’s browser with an authentication code or access token.
But this may only work with in a test scenario... I also noticed that it had to be https:// so you would need to put in the https://<name-of-server>/ebase/ufsreturn
Anyway... might be worth a try?
Steve
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Who is online
Users browsing this forum: No registered users and 4 guests