+ Start a Discussion
Sami ShakithSami Shakith 

Not getting session Id in identity provider (Salesforce to salesforce integration using canvas application)

Hi,

I am trying to develop S2S integration using canvas application. For that i followed http://www.jitendrazaa.com/blog/salesforce/salesforce-to-salesforce-integration-using-canvas/ In that he asked to develop a VF(in service provider) which will be called in identity provider. 

VF code is as below
<apex:page showHeader="false">
    
    <script type="text/javascript" src="{!URLFOR($Resource.CanvasSDK,'SalesforceCanvasJavascriptSDK-master/js/canvas-all.js')}" />
    
    <script type="text/javascript">
        
        var sid="{!GETSESSIONID()}".substr(1,30) +'...';
    
    	function refreshSR(){
        	Sfdc.canvas.client.refreshSignedRequest(function(data){
            	
                if(data.status == 200){
                	var signedRequest = data.payload.response;
                    var part = signedRequest.split('.')[1];
                    var obj = JSON.parse(Sfdc.canvas.decode(part));
                    updateDisplay(obj) ;
                } 
            }); 
        }
    
    function updateDisplay(obj){
    	setValue('spSessionId', sid);
        setValue('ipOAuth', obj.client.oauthToken.substr(1,30)+'...');
        setValue('ipUser', obj.context.user.fullName);
        setValue('ipOrg', obj.context.organization.name);
        setValue('ipRefresh', obj.client.refreshToken.substr(1,30)+'...');
    }
    
    function setValue(eleId,val)
    {
       	var domEl = document.getElementById(eleId);
        if(domEl){
        	domEl.innerHTML = val;    
        }
    }
    
    Sfdc.canvas.onReady(function(){
    	refreshSR();
    });
         
    </script>
          
        <b> <u> Service Provider Org </u></b>  
        I am Canvas App from Salesforce Domain <b> Jitendra.zaa5@gmail.com </b>      
        User : {!$User.FirstName} {!$User.LastName} 
        Org : {!$Organization.Name}
        Session Id : <span id="spSessionId"></span>    

<hr />
 
        <b> <u> Identity Provider Org  - Current Org </u> </b>
        User : <span id="ipUser"></span>
         Org : <span id="ipOrg"></span>
         OAUth Token : <span id="ipOAuth"></span>
        Refresh Token : <span id="ipRefresh"></span>
     
</apex:page>

My VF page showing without the session id and informations of identity provider in identity provider entity as below
User-added image

How to get those values. I Need some one help to resolve it. 

Thanks.
 
surasura
If I am not mistaken you havent put any value/variable to print as session Id .
Sami ShakithSami Shakith
Thanks for your reply sura. 

where to mention the value?
surasura
you can get the Session id in page with below code
{!$Api.Session_ID}
so modifiy your code as below 

 
<b> <u> Service Provider Org </u></b> 

        I am Canvas App from Salesforce Domain <b> Jitendra.zaa5@gmail.com </b>     

        User : {!$User.FirstName} {!$User.LastName}

        Org : {!$Organization.Name}

        Session Id : <span id="spSessionId"> {!$Api.Session_ID}</span>

 
Sami ShakithSami Shakith
Then how to get the identity provider information? please tell me.