• suresh somu 2
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I tried to connect another salesforce application and get access token. but i am getting error while converting my url to code.

apex class:

public class WebServerFlow {
    public String redirecturi     {set;get;}
    public String code             {set;get;}
    public String url              {set;get;}
    public String jsonResponse     {set;get;}
    public String accessToken     {set;get;}
    public ServerData__c sp     {set;get;}
    public WebServerFlow(){
        redirecturi ='https://ap5.salesforce.com/apex/ResponsePage';
        sp = [select ClientId__c, ClientSecret__c from ServerData__c];
    }
    public pageReference callCode(){
        url = 'https://login.salesforce.com/services/oauth2/authorize?response_type=code&';
        url = url+'client_id='+sp.ClientId__c+'&redirect_uri='+redirecturi;
        pageReference p = new pageReference(url);
        return p;
    }

VF page:
main page:
<apex:page controller="WebServerFlow">
    <apex:form >
        <apex:commandButton value="Code" action="{!callCode}"/>
        {!url}
    </apex:form>
</apex:page>

response page:
<apex:page >
</apex:page>

when i click on code, it is generating this url:
""https://login.salesforce.com/services/oauth2/authorize?client_id="CLIENTID from table"&redirect_uri=https%3A%2F%2Fap5.salesforce.com%2Fapex%2FResponsePage&response_type=code" and showing below error as 
"This site can’t be reached
The webpage at https://login.salesforce.com/services/oauth2/authorize?client_id="CLIENTID from table"&redirect_uri=https%3A%2F%2Fap5.salesforce.com%2Fapex%2FResponsePage&response_type=code might be temporarily down or it may have moved permanently to a new web address.
ERR_INVALID_RESPONSE"

instead of going to response page. 

Please help me to resolve this error.
Hi Everyone,

I need capital info solution salesforce integration materials. if anyone is having any pdf doc. Please send me