1

So I'm building an application which exports contacts from various CRMs and unifies that data to run marketing reports on their contacts.

I was easily able to get HubSpot and InfusionSoft working with their Oauth2 apis, and I was hoping that salesforce would go just as easily.

My desired flow is to redirect the user from their private domain (e.g. user1.appDomain.com) to the salesforce site to log them in. Then I want to redirect them back to their private domain (user1.appDomain.com/oauthReturn) with their access token so I can start importing their data.

I registered an external application in my developer salesforce account, and have received my oauth tokens, but I need to know a few things (that googling hasn't solved yet).

So I need to know a few things first.

  • Will salesforce allow me to pass in the redirect url from the user's private domain?
  • Can I even do this with Oauth2 and php? The documentation is unnecessarily confusing, and most of the libraries are still using api tokens and all of the relevant documentation I can find is 2-3 years out of date.

If anyone knows where I should be looking to find these answers that would be extraordinarily helpful.

Thanks so much for your help!

1
  • Or if this is too much to ask, is it possible to export an external user's salesforce contacts with the api?
    – kisgal21
    Commented Sep 2, 2015 at 17:30

1 Answer 1

0

https://help.salesforce.com/apex/HTViewSolution?urlname=Spring-15-Use-Multiple-Callback-URLs-for-Connected-Apps&language=en_US

This help article is just a notice saying that you can enter in multiple return urls, rather than specifying a wildcard, but since we're programmatically spinning up subdomains, this means I might have to drop salesforce support.

!!EDIT!! Actually, there is a {state} variable you can pass into the GET call to the authorize endpoint which will return to your redirectUrl. So instead of specifying a wildcard callback url, you can specify a centralized one and pass in a (url encoded) identifier and redirect the user back to their proper location. Kinda a hack, but working with salesforce always seems to be so.

Also, for logging in a user and getting access to their salesforce account via oauth, I think the flow is going to be:

GET:

https://\login.salesforce.com/services/oauth2/authorize?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}&state={whatever_you_want_sent_to_the_redirect_url}

Which returns a GET code to your redirect Url, which then in turn is posted over to

POST:

https://\login.salesforce.com/services/oauth2/token

code: {access code you just received}

grant_type: 'authorization_code'

client_id: {from app config}

client_id: {from app config}

redirect_uri: {from app config}

However I cannot get my security settings to work so I always get an error, but it does seem that what I was asking is possible.

This just gets your oauth tokens which you can use to get the contact info (I'll post when I get past my authentication issue)

If I'm doing anything else wrong I'll update the answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .