You need to sign in to do that
Don't have an account?
AK-2
Canvas application using OAuth- unable to retrieve Token
I am playing with a canvas app that's a couple of web pages (html) with some js. I am using oauth for authenticating with Salesforce. In the javascript, I have index.html which starts the authentication flow using Sfdc.canvas.oauth.login as shown below. The page redirects to index1.html after login:
What I am noticing is that even when I am logged into my dev org, the page Sfdc.canvas.oauth.loggedin() is always false. If I am logged in, the page correctly redirects me to my callback page index1 and if I am not logged into the salesforce on the browser, the app correctly redirects me to the login page (I am using mydomain). But after I log-in, I can't seem to get the context or the token in index1.html here:
What am I missing? Why is the token blank?
Thank you.
if (! Sfdc.canvas.oauth.loggedin()) { uri = Sfdc.canvas.oauth.loginUrl(); Sfdc.canvas.oauth.login( {uri : uri, params: { response_type : "token", client_id : "code", redirect_uri : encodeURIComponent( "https://localhost:8181/index1.html") }}); } else { Sfdc.canvas.oauth.logout(); login.innerHTML = "Login"; Sfdc.canvas.byId("oauth").innerHTML = ""; }
What I am noticing is that even when I am logged into my dev org, the page Sfdc.canvas.oauth.loggedin() is always false. If I am logged in, the page correctly redirects me to my callback page index1 and if I am not logged into the salesforce on the browser, the app correctly redirects me to the login page (I am using mydomain). But after I log-in, I can't seem to get the context or the token in index1.html here:
var login = Sfdc.canvas.byId("login"), loggedIn = Sfdc.canvas.oauth.loggedin(), token = Sfdc.canvas.oauth.token();
What am I missing? Why is the token blank?
Thank you.
All Answers