Based on the canvas documentation, i have setup the canvas app so that the authentication is OAuth. Also, I have been in the assumption that OAuth flow can be handled entirely through javascript rather than on the server side. From the topic in Canvas Framework SDK documentation i am trying to run this javascript code and ended with a non-responsive page. I am thinking the msg in the function below would be the cause of the issue. But I am wondering where could i get the value for "msg" in callback function as given below and do not know where it is coming from.

The shift to using OAuth flow is because of this issue which i posted here yesterday. The issue was SAP ABAP does not support java and the methods to parse the signed request is not supported. Now i am getting another type of issue. Although in the canvas framework documentation it has been said that canvas is platform independent. How it is? Any suggestion please.


  1. do we need to access the context from the redirect URI page?

The code snippet below has been taken from the canvas framework sdk pdf under the topic

"Getting Context in Your Canvas App"

function callback(msg) {
 if (msg.status !== 200) {
    alert("Error: " + msg.status);
  alert("Payload: ", msg.payload);
var ctxlink = Sfdc.canvas.byId("ctxlink");
var client = Sfdc.canvas.oauth.client();
ctxlink.onclick=function() {
   Sfdc.canvas.client.ctx(callback, client)};
<a id="ctxlink" href="#">Get Context</a>

Yes, you can do a pure JS OAuth flow with canvas

It's up to you however to kick off the flow

function loginHandler(e) {

    var uri;

    if (! Sfdc.canvas.oauth.loggedin()) {
        uri = Sfdc.canvas.oauth.loginUrl();
                {uri : uri,
                 params: {
                    response_type : "token",
                    client_id : "<%=consumerKey%>",
                    redirect_uri : encodeURIComponent("<%=callbackUrl%>")
    else {
    return false;

Above is a function I call when the user clicks on a login/logout link. Note, you will need to replace the consumerKey and callback URL with your values. For callbackUrl we supply an html page as part of our SDK. I recommend you use that. Once you have successfully gone through the OAuth dance you should be able call your script above. i.e "Getting Context in Your Canvas App"

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.