Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

If I put this link in my web browser (I put them on separate lines for readability):

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

and log in, it redirects me to the redirect_uri appended with a hash of all the important information I need. I want to use my own redirect_uri, so I modified the callback URL field for the application, and modified my request:

https://login.salesforce.com/services/oauth2/authorize
?response_type=token
&client_id=MY_CONSUMER_KEY
&redirect_uri=MY_CUSTOM_URI

I can log in like I would in the previous example, and it redirects me correctly to my custom uri, but without the refresh token in the hash. Any ideas?

share|improve this question
    
is there a subsequent redirect happening on your side? (eg HTTPS to HTTP, or stripping of WWW subdomain) –  user320 Jan 23 '13 at 10:28

1 Answer 1

up vote 4 down vote accepted

According to the docs:

The refresh token for the user-agent flow is only issued under one of the following circumstances:

User-agent flow is not intended for use with web apps (which is what it looks like you're trying to do). Use web server flow instead.

share|improve this answer
    
There is another undocumented case in which the refresh token is returned in user-agent flow, when the callback url uses the http protocol and the host is localhost. –  xn. Dec 6 '13 at 22:04
    
Good call, @xn. - added http://localhost:port/ - thanks! –  metadaddy Dec 9 '13 at 6:28
    
@metadaddy when I tried login.salesforce.com/services/oauth2/… &client_id=MY_ClientId &redirect_uri=localhost:8080 with MY_ClientId replaced with the consumer key and localhost:8080 as callback url in browser below error coming error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20conf‌​iguration what could be the possible reason? –  Shebin Mathew Dec 9 '13 at 7:11
    
@ShebinMathew There is often some latency when changing redirect URI - see salesforce.stackexchange.com/a/12248/67 –  metadaddy Dec 9 '13 at 20:35
    
@xn too bad it doesn't work when using a self-signed certificate locally on https (i.e. localhost) –  contactmatt Jul 22 at 23:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.