4

I am a beginner in Angular JS and Salesforce.

I am building a hybrid application.

I am using the USER AGENT authentication flow

I used the following url :

https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=consumer_key&redirect_uri=https://localhost:63342/www/index.html#/

I got the result as expected with the access token but did not get the refresh token.

Then i found this

The refresh token is only returned if the redirect URI is https://login.salesforce.com/services/oauth2/success or used with a custom protocol that is not HTTPS.

So I changed the redirect_uri in my url as :

https://login.salesforce.com/services/oauth2/authorize?response_type=token&client_id=3MVG9ZL0ppGP5UrCf3JELrQofxTN1p28Y0qBjNy67uUtwoVl8i0LX6ntfchfUlDJoeso1xKRxGHx_Tzk_SAiK&redirect_uri=https://login.salesforce.com/services/oauth2/success

I got the refresh token.

But then the page is stuck up at the below link

https://login.salesforce.com/services/oauth2/success#access_token=access_token&refresh_token=refresh_token&instance_url=https%3A%2F%2Fap2.salesforce.com&id=id&issued_at=1444119251446&signature=sign&scope=scope&token_type=Bearer

How do i make it redirect back to my app link

https://localhost:63342/www/index.html#/

Thanks in advance.

2 Answers 2

3

I got the Answer.

I just changed the callback url in connected app settings to my app url and we have to use http instead of https.

2
  • 1
    Thanks for posting your solution. Please accept your answer as the solution to close your question.
    – Rob
    Commented Oct 6, 2015 at 9:26
  • 1
    can you post the example url here? Commented Jul 3, 2018 at 9:39
0

This only works because your redirect uri is a localhost. The redirect uri needs to satisfy these conditions:

enter image description here

http://localhost is also another condition that will allow the refresh_token to be passed back.

Reference Resource: https://help.salesforce.com/articleView?id=remoteaccess_oauth_user_agent_flow.htm&type=5

You must log in to answer this question.

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