function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ajay Patel 54Ajay Patel 54 

Integration Salesforce 2 salesforce without @RestRessource

Hii need help 
i am getting error ..When trying to get the access token 
Here is my code 

error::whenc clicking button error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration

///Apex class public class OpportunityTriggerCreateOpp_HandlerClass {    
public static final string client_Id='3MVG9fe4g9fhX0E5D96.SbSaoF1aZrrAtrdkkQOCvZBwTXOX8o.xKXj_VnKMUVbC8_Rl1JBm_Fzfi6xw8W5nBNic';    
public static final string consumer_Secret='121B828EA2A3BA970CCFA6380002E95E06242299329B3C4EB69FF863BB63';    

public static String redirect_URI ='';       
 public static PageReference dosubmit(){            
String authorization_endpoint = '';         String scope = '';        
String final_EndPoint =  authorization_endpoint+'?client_id='+client_Id+'&redirect_uri='+redirect_URI+'&response_type=code';          
PageReference pageRef = new PageReference(final_EndPoint);        
return pageRef;    
public static void doFetchAccessToken(){            
String encodedString = EncodingUtil.base64Encode(Blob.valueOf(client_Id+':'+consumer_Secret));         String endPoint = '';                 String oAuthCode = ApexPages.currentPage().getParameters().get('code');         String requestBody = 'grant_type=authorization_code&code='+oAuthCode+'&redirect_uri='+redirect_URI;       
 String errorMessage ='';            
    HttpRequest httpReq = new HttpRequest();         HttpResponse httpRes = new HttpResponse();        
Http http = new Http();        
​​​​​​ httpReq.setMethod('POST');        httpReq.setEndPoint(endPoint);         httpReq.setHeader('Authorization' , 'Basic '+encodedString);       
httpReq.setHeader('Content-Type' , 'application/json');         httpReq.setBody(requestBody);        
httpRes = http.send(httpReq);         system.debug(httpRes.getStatusCode());         system.debug(httpRes.getBody());  
  } }

////vf page
<apex:page Controller="OpportunityTriggerCreateOpp_HandlerClass"  >     <apex:form >        
         <apex:pageBlock >            
              <apex:commandButton action="{!dosubmit}" value="Do Submit"/>      
ShivankurShivankur (Salesforce Developers) 
Hi Ajay,

The error you are getting should be due to configuration mismatch.

As you are using a Connected App for the integration with the third party app, the redirect_uri in this case is the Callback URL as configured in the Connected App being utilized.

Please check if its matching as configured with your Connected App in the org and try to match it.

Hope above information helps, Please mark as Best Answer so that it can help others in the future.