
http://wiki.developerforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com
I want to get a refresh token for my desktop app, and store the refresh token. I am a little stuck on what I need to do to do this. The article says:
In this flow, the client application directs (1) the user to a URL at the authorization server of the form: https://login.salesforce.com/services/oauth2/authorize?response_type=token& client_id=&redirect_uri=&display=touch&state=
On a browser, this redirects to a URL which takes the user to the SFDC login page, and then to a page asking the user to approve access to the application. So my first question is, in the Java app, how do I open the URL so that it redirects to the browser, while maintaining control of the browser? I tried JPaneEditor, it did not seem to work. The article then continues:
Now, rather than sending an authentication code to the client and it retrieving the access token via a POST request, a redirect is returned (3) containing several parameters in a URL fragment (i.e. after the hash '#' sign) - for example: myapp:oauth#.access_token=00D50000000IZ3Z%21AQ0AQI6qUiQpGCAlNVAEOugF7J6Lr34LHSUUQZ_S4rnPzShAsJzG0qjW1XEx5R6kDORlWE2r9QXJpfAkAkq8V9k_V0PbXYjN&refresh_token=5Aep861eQO5D.6wJBuW5bbARbbxQ8hssCnY1dw3qi59jeys7ob.H_xM395_RJHukNjeustDru8BiA%3D%3D&instance_url=https%3A%2F%2Fna3.salesforce.com&id=https%3A%2F%2Flogin.salesforce.com%2Fid%2F00D50000000IZ3ZEAW%2F00550000001fg5OAAQ&issued_at=1298926970349&signature=Y5ici2QZsudYyH%2F4YWcJd1s3P89mLJPVsO0plVoHD4o%3D&state=mystate Since these parameters are passed in a fragment, they will remain on the client device, and will not be passed in an HTTP GET to the redirect URI. Note that the redirect URI may have a custom scheme, configured in the desktop/device OS to invoke a callback in the native app, for example, myapp:oauth, or it may have the https scheme. A native application can directly parse the incoming parameters from the fragment; in contrast a browser-based application would rely on JavaScript, served from the https redirect URI, which would have access to the fragment and its parameters.
So how exactly does my desktop app read the URL fragment at this point?
Would appreocate any help, I am really stuck here.
1 answer
You can post your question in the Dev boards : http://boards.developerforce.com/t5/Java-Development/bd-p/JAVA_development
if our suggestion(s) worked, let us know by marking the answer as "Best Answer" right under the comment.This will help the rest of the community should they have a similar issue in the future. Thank you!
Shivanath