10

FINAL*

Ok, so first lesson, do not stay up to late

Second for those that may need:

  1. First URL needs to end in authorization This returns a CODE
  2. the second needs to be an HTTPRequest with response with the url ending in token This will return the appropriate results.

Oh, and set your callback to https://na1.salesforce.com/apex/pagename

UPDATE

I go the original stuff worked out now the issue is that I need to have the callback url be a visual force page that could be on any instance

Right now I have it set to:

https://login.salesforce.com/apex/pagename

it does take me to the page but will not pass along the results of the oAuth

if I changed the call back url to:

na15.salesforce.com/apex/pagename

the parameters are there.

As with any managed package it could be installed on any instance so how the heck do I get it to return the the users instance / package page / along with the results of the oAuth...


I need to authorize a connected app that is 100% native inside of salesforce.

That part I got down.

BUT

I end up at the the redirect URL of https://login.salesforce.com/services/oauth2/success which just displays "Remote Access Authorized" or something like that....

I need the refresh token, so how do I get the user redirected back to the visual force page to capture the refresh token?

I must be missing something simple.....

Keep in mind that the page could be on any instance.....

2
  • 1
    when you set the callback to na1.salesforce.com, does that work for any user of your managed package, regardless of their instance? I would think the user would have to specify their own instance. Jul 12, 2016 at 15:51
  • @DavidCheng - Use https://ap1.salesforce.com to be useable for any instance including EMEA etc
    – Eric
    Jul 12, 2016 at 18:34

2 Answers 2

2

Mention the redirect URL as your visuslforce page only instead of oauth success url.The VF Url will have access token that you can get using apexpages.currentpage.parameters.get('refresh token')

7
  • How do I do that when I do not know what instance it may be installed on? Since the callback url must match the connected app setting I cannot just set it to the current instance...
    – Eric
    Jul 27, 2014 at 3:08
  • Disregard. I had a debug code that was causing the issue of null reference.......Thank you for letting me know it should be possible. That kept me going and digging into it
    – Eric
    Jul 27, 2014 at 3:52
  • Ok. So I am getting it coming back to the page but there are no parameters returned.....ugh
    – Eric
    Jul 27, 2014 at 4:24
  • You will need a site page that can be accessed by anybody.Once you obtain token and server URL redirect User to Server URL . Jul 27, 2014 at 5:49
  • github.com/logontokartik/Picklist-Manager you can start from this . @logonkarthik has already done some work .begin from here . Jul 27, 2014 at 5:50
0

Was this ever solved? Redirecting from a server is definitely insecure and would not pass a appexchange review.

2
  • Also apexpages.currentpage.parameters.get('refresh token') and {!$CurrentPage.parameters.anytokenparam} does not work as the callback adds a # before the parameters before the call back. Jul 28, 2017 at 5:15
  • Can we have a look at the code here?
    – PSH
    Jan 19, 2018 at 1:17

You must log in to answer this question.

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