views:

69

answers:

1

Hi,

I'm trying to get my facebook graph oauth setup using javascript's window location methods.

Here is my code so far:

function fbLog() {
var clientID = '11502353444318540727';
var redirecturi = 'http://google.com';
var clientSecret = '6987d02323442423231f8b9da767b060e9';
var codeURI;
$('#fbLogin').click(function() {
  window.location = 'https://graph.facebook.com/oauth/authorize?client_id=' + clientID + '&display=touch&redirect_uri='+ redirecturi + '&type=user_agent';
codeURI = window.location.href;
codeURI.split('=');
console.log(codeURI);
codeURI = codeURI.split('=');
codeURI = codeURI[1];
console.log(codeURI);
codeURI = codeURI.split('#');
codeURI = codeURI[0];
console.log('mega fun');
window.open = 'https://graph.facebook.com/oauth/access_token?client_id=' + clientID + '&redirect_uri=' + redirecturi + '&client_secret=' + clientSecret + '&code=' + codeURI
});

}

when I set codeURI to window.location.href, is that original call back page dead?

I'm super confused. Have I switched to a different window when I try to get the codeURI?

A: 

You have to assume that as soon as you set window.location, the browser will load a new page and all code on the current page will stop running. Don't try to do anything afterwards.

As far as I can tell, all you need here is to do things in a different order.

hobbs
Thanks, It looks like I need to check at document.load if the callbacked url contains the word 'code'.. Do i need a regex?
fordays