Select to view content in your preferred language

Javascript API ArcGIS Online sign in error

1327
3
Jump to solution
08-28-2012 03:28 AM
LukeStewart
Occasional Contributor
I am developing an application and trying to use the Portal tools now built into the JS API. I have managed to get it searching ArcGIS Online items and add them to the map but am having issues trying to sign into my organisational account to view private items. I am using the code from the samples (below) to try and sign in. It worked a couple of times but I can now not get it to sign in and have made no changes to the code that would break it. I get the error in the attached image in firebug.
Can anyone shed any light on this?

function signIn() {
var signInLink = dojo.byId('signIn');
if (signInLink.innerHTML.indexOf('In') !== -1) {
portal.signIn().then(function (loggedInUser) {
signInLink.innerHTML = "Sign Out";
}, function (error) {
signInLink.innerHTML = 'Sign In'; //error so reset sign in link
});
} else {
portal.signOut().then(function (portalInfo) {
signInLink.innerHTML = "Sign In";
});
}
}

[ATTACH=CONFIG]17281[/ATTACH]
0 Kudos
1 Solution

Accepted Solutions
LukeStewart
Occasional Contributor
I finally figured this one out. In the end it has nothing to do with SSL or permissions and everything to do with ####.

I had <a href="#"  tags in my JS and when clicking on links with this syntx a # was added to the end of the main url e.g something/something.html#. This # was subsequently causing the ArcGIS Online login to fail.

I have now removed all the #'s and the login is working fine. Of course this has meant some other parts of the application do not work in certain browsers but that is another story.

View solution in original post

0 Kudos
3 Replies
KellyHutchins
Esri Frequent Contributor
Luke,

signIn uses the Identity Manager to allow users to enter their credentials. The IdentityManager requires SSL because we don't want to send credentials via non-SSL channels.

If you are in a development/testing machine that doesn't have a valid SSL certificate you can override the restriction using something like the code below to test the sign-in process. Just remember to remove this code before moving to a production environment.
    dojo.addOnLoad(function() {
      esri.config.defaults.io.proxyUrl = proxyUrl;
 
      esri.id.setProtocolErrorHandler(function() {
                // return true from this handler if you want to proceed anyway
                // with the protocol mismatch
                return window.confirm("This application is going to send your credentials across a non secure protocal.  Proceed?");
     
              });
    });  

LukeStewart
Occasional Contributor
Hi,

It is a development environment but I am running it through HTTPS on my IIS. I have also tried the work around you provided and it is still not working.

The error in FireBug is telling me XMLHttpRequest cannot load..... https://127.0.0.1 is not allowed by Access-Control-Allow-Origin.

Then 3:

TypeErrors

It is some kind of security issue and I do not know very much about this area. Is there anything else you can suggest that may help to get this working??

Thanks
0 Kudos
LukeStewart
Occasional Contributor
I finally figured this one out. In the end it has nothing to do with SSL or permissions and everything to do with ####.

I had <a href="#"  tags in my JS and when clicking on links with this syntx a # was added to the end of the main url e.g something/something.html#. This # was subsequently causing the ArcGIS Online login to fail.

I have now removed all the #'s and the login is working fine. Of course this has meant some other parts of the application do not work in certain browsers but that is another story.
0 Kudos