I would like to pass a refresh token to my server to store and use for offline access. I am currently using an iframe into the server and, in Apex, getting the session_id and passing it to the server. Is there any way to get a refresh token or the equivalent access token for offline access?

The Auth.AuthToken class seems to only get the access token and now has the ability to refresh it, but does not have direct access to the refresh token, yes?

Is there some other access credential I have the ability to get inside of Apex?


Auth.AuthToken is for allowing users to be created in salesforce.com from a third-party authorization flow (assuming my understanding is correct). What you're looking for is the web server oauth flow, where your server redirects to salesforce.com, the user grants access, if not already granted, and then your server receives a refresh token (if requested in the scope and allowed by the connected app settings). You'll find details on this flow in Help & Training under OAuth 2.0 Web Server Authentication Flow. You can choose to make this a canvas app and retain the OAuth capabilities as well, if desired.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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