Skip to content

Instantly share code, notes, and snippets.

@junojisan
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junojisan/7e0dbb360ccf63fde212 to your computer and use it in GitHub Desktop.
Save junojisan/7e0dbb360ccf63fde212 to your computer and use it in GitHub Desktop.
public with sharing class OAuthInitiateController {
public static final String CLIENT_ID = <CLIENT_ID>;
public static final String CLIENT_SECRET = <CLIENT_SECRET>;
public static final String CALLBACK_URL = 'https://xxxx/apex/OAuthCallback';
public PageReference initiate(){
String authorizeUrl = 'https://login.salesforce.com/services/oauth2/authorize';
authorizeUrl += '?response_type=code';
authorizeUrl += '&client_id=' + CLIENT_ID;
authorizeUrl += '&redirect_uri=' + CALLBACK_URL;
authorizeUrl += '&prompt=login consent';
PageReference pref = new PageReference(authorizeUrl);
pref.setRedirect(true);
return pref;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment