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
Sami ShakithSami Shakith 

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


I am trying to develop S2S integration using canvas application. For that i followed 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(){
                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('ipRefresh', obj.client.refreshToken.substr(1,30)+'...');
    function setValue(eleId,val)
       	var domEl = document.getElementById(eleId);
        	domEl.innerHTML = val;    
        <b> <u> Service Provider Org </u></b>  
        I am Canvas App from Salesforce Domain <b> </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>
My VF page showing without the session id and informations of identity provider as belowUser-added image
How to get those values. I Need some one help to resolve it. 

Hi Sami, It sems issue with Connected App setting, Can you please check your developer console of page by pressing "Ctrl+Shift+J" if you are using googe chrome. If possible please paste screen shot.
Sami ShakithSami Shakith
Thanks for your reply Jitendra.

I have sorted out this by another code.

Below code working fine in my dev account.
<apex:page showHeader="false">
<script type='text/javascript' src='/canvas/sdk/js/canvas-all.js'/>
    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));
    function updateDisplay(obj) {
        var oauth = document.getElementById('oauth');
        oauth.innerHTML = obj.client.oauthToken;
        var user = document.getElementById('user');
        user.innerHTML = obj.context.user.fullName;
        var org = document.getElementById('org');
        org.innerHTML =;
Service Provider User: {!$User.FirstName} {!$User.LastName}<br/>
Service Provider Org: {!$Organization.Name}<br/>
Identity Provider User: <span id="user"></span><br/>
Identity Provider Org: <span id="org"></span><br/>
Identity Provider OAuth Token: <span id="oauth"></span><br/>
<input id="refresh" type="button" value="Refresh SR" onclick="refreshSR();"/>