0

I have implemented Canvas App integration and facing an issue when i set the Permitted Users = All users may self-authorize.

The issue that i am facing is once the canvas app receives the request parameter _sfdc_canvas_auth = user_approval_required and then initiates the approve or deny OAuth flow.

The moments users clicks the Allow button on the Pop-up , i am expecting the signed request in the canvas app which is not happening. It is opening the Pop-up recursively sending same request with sfdc_canvas_auth = user_approval_required .

In the below code the control is never going to Else block. Please suggest.

Below is the code reference

Sfdc.canvas(function() {

         console.log("IS LOGGED IN : "+Sfdc.canvas.oauth.loggedin());
         console.log("IS AUTH TOKEN IN : "+Sfdc.canvas.oauth.token());



             if (!Sfdc.canvas.oauth.loggedin()) {
                    var uri = Sfdc.canvas.oauth.loginUrl();
                    Sfdc.canvas.oauth.login(
                        {uri : uri,
                            params: {
                                response_type : 'code',
                                client_id: '3MVG9ZL0ppGP5UrBvwUERnW1e5Jl5Lt3Ug6KklFITAbC38I0AylpTSDWhuXst6LiASFdrwFT95tx6F57FZ69l',
                                redirect_uri : encodeURIComponent(
                                        'https://crmitdemos.crmit.com:8444/SFCanvasCustomAppWithSignedRequest/callback.html')
                       }});
                }
                else {
                     Sfdc.canvas.client.repost({refresh : true});
                }
       });

The callback html contains below code

try {
        window.opener.Sfdc.canvas.oauth.childWindowUnloadNotification(self.location.hash);
    } catch (ignore) {}
    self.close();

Call back URL configured in App.

https://crmitdemos.crmit.com:8444/SFCanvasCustomAppWithSignedRequest/callback.html

Canvas App configuration Details

enter image description here

0

There is a similar question on that, it might help you: Implementing the self-authorization flow of signed request authentication for a canvas app

If it didn't work then please attach your Canvas App configuration details.

  • It didn't work, i have attached the canvas app configurations details . Thanks. – Sharan Desai Feb 8 '17 at 9:05
  • What's your OAuth callback URL in Canvas App configuration? – user2809299 Feb 8 '17 at 9:07
  • What's your code for handling the GET request which you are receiving at the first time when you received _sfdc_canvas_auth = user_approval_required, How are you initiating the oAuth approval flow – user2809299 Feb 8 '17 at 9:52
  • 1
    @SharanDesai, the only concern i'm seeing over here is I think you are using a single page in both the case, whether you came with GET request from salesforce or POST request. there are some issues with your oAuth Flow. Try to differentiate the things, handle oAuth flow at server side and then once user approved that flow repost the signed Request. I came across a Demo Flow from salesforce, just skip to the User Based Authetication flow and see if it can make any sense: dreamforce.vidyard.com/watch/AT4-nH0mvvcm0DGudoVLTg – user2809299 Feb 8 '17 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.