Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- request.setEndPoint('https://login.salesforce.com/services/oauth/token');
- request.setMethod('POST');
- String reqbody = 'grant_type=password&client_id='+clientId+'&client_secret='+clientSecret+'&username='+username+'&password='+password;
- request.setBody(reqbody);
- Http p=new Http();
- HttpResponse response=p.send(request);
- result=response.getBody();
- system.debug('@@@result = '+result);
- return null;
- <apex:pageBlockSection title="OAuth2.0 username & Password"
- collapsible="false">
- <apex:pageBlockSectionItem >
- <apex:outputLabel value="ClientID"/>
- <apex:inputText value="{!ClientID}"/>
- </apex:pageBlockSectionItem>
- <apex:pageBlockSectionItem >
- <apex:outputLabel value="ClientSecret"/>
- <apex:inputText value="{!ClientSecret}"/>
- </apex:pageBlockSectionItem>
- <apex:pageBlockSectionItem >
- <apex:outputLabel value="UserName"/>
- <apex:inputText value="{!UserName}"/>
- </apex:pageBlockSectionItem>
- <apex:pageBlockSectionItem >
- <apex:outputLabel value="Password"/>
- <apex:inputText value="{!Password}"/>
- </apex:pageBlockSectionItem>
- </apex:pageBlockSection>
- <apex:pageBlockButtons >
- <apex:commandButton value="Get Access Token"
- action="{!GetAccessToken}"
- reRender="token"/>
- </apex:pageBlockButtons>
- {!accesstoken}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement