Advertisement
Guest User

Untitled

a guest
Jun 15th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. request.setEndPoint('https://login.salesforce.com/services/oauth/token');
  2.  
  3. request.setMethod('POST');
  4.  
  5. String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
  6.  
  7. request.setBody(reqbody);
  8.  
  9. Http p=new Http();
  10.  
  11. HttpResponse response=p.send(request);
  12.  
  13. result=response.getBody();
  14.  
  15. system.debug('@@@result = '+result);
  16.  
  17. return null;
  18.  
  19. <apex:pageBlockSection title="OAuth2.0 username & Password"
  20. collapsible="false">
  21.  
  22.  
  23. <apex:pageBlockSectionItem >
  24. <apex:outputLabel value="ClientID"/>
  25.  
  26. <apex:inputText value="{!ClientID}"/>
  27.  
  28. </apex:pageBlockSectionItem>
  29.  
  30. <apex:pageBlockSectionItem >
  31. <apex:outputLabel value="ClientSecret"/>
  32.  
  33. <apex:inputText value="{!ClientSecret}"/>
  34.  
  35. </apex:pageBlockSectionItem>
  36.  
  37.  
  38. <apex:pageBlockSectionItem >
  39. <apex:outputLabel value="UserName"/>
  40.  
  41. <apex:inputText value="{!UserName}"/>
  42.  
  43. </apex:pageBlockSectionItem>
  44.  
  45. <apex:pageBlockSectionItem >
  46. <apex:outputLabel value="Password"/>
  47.  
  48. <apex:inputText value="{!Password}"/>
  49.  
  50. </apex:pageBlockSectionItem>
  51.  
  52.  
  53. </apex:pageBlockSection>
  54.  
  55. <apex:pageBlockButtons >
  56.  
  57. <apex:commandButton value="Get Access Token"
  58. action="{!GetAccessToken}"
  59. reRender="token"/>
  60.  
  61. </apex:pageBlockButtons>
  62.  
  63. {!accesstoken}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement