3

I am currenty trying to write my first ever stack exchange application and was using the SE Jaavascript SDK v 2.0 for this purpose.

I am stuck on the point of authenticating the user. I followed the steps mentioned here

I am able to complete the call to SE.init successfully, However, when I call SE.authenticate, I get a login window where-in I login using my StackExchange account. At this point, I get an error that says Unexpected domain on proxy URL.

I would like to point out that I am using a cloud-based IDE at nitrous.io and hence I can test-run this application within the preview URL provided by them. In my case, I access the preview URL as follows :

http://cybertron-nodejs-11139.apse1.actionbox.io:3000/files/index.html

Here is my code snippet for the JS file that contains all the initialization and authentication logic:

$(document).ready(function() {
  SE.init({clientId: 1880, 
    key: '396D79cbzmt3w*Pf)E7AUw((', 
    // Used for cross domain communication, it will be validated
    channelUrl: 'http://cybertron-nodejs-11139.apse1.actionbox.io:3000/files/blank.html',
    // Called when all initialization is finished
    complete: function(data) { 
        console.log(data)
        $('#login-button')
            .removeAttr('disabled')
            .text('Run Example With Version '+data.version); 
      }
  });

  $("#login-button").click(function() {

    SE.authenticate({
        success: function(data) { 
            alert(
                'User Authorized with account id = ' + 
                data.networkUsers[0].account_id + ', got access token = ' + 
                data.accessToken
            ); 
          },
        error: function(data) { 
            alert('An error occurred:\n' + data.errorName + '\n' + data.errorMessage); 
        },
        networkUsers: true
    });
  });

1 Answer 1

3

Your apps registered domain must match that the url passed as channelUrl.

You'll need to update your app's domain from actionbox.io to cybertron-nodejs-11139.apse1.actionbox.io (or whatever other full, stable domain your app ends up at).

2
  • Thanks for the note. I updated my app's OAuth URL and now I get stuck at the authentication page. Chrome gives me the following error message: Unable to post message to cybertron-nodejs-11139.apse1.actionbox.io. Recipient has origin cybertron-nodejs-11139.apse1.actionbox.io:3000. I cannot run an HTTP server on port 80 since that is already in use. Is there a way I can work around this? Aug 12, 2013 at 18:38
  • I finally managed to get this working. I realized, that working within the preview URL of the cloud IDE provider is not going to solve the problem due to the port number constraints. I deployed this app on heroku and am now able to get this working. Thanks a ton for the guidance. Aug 17, 2013 at 5:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .