Hi,
Thank for your answer.
I have already found something that it is working, it is not very elegant but is working.
I’m not sure if I could use your solution. The problem is that I just open the window this way.
var url = “https://api.twitter.com/oauth/authorize?oauth_token=EWpGlOkl9NodUIWxYeFUi5PHI8oBCK0UxmzaEQbLOA”;
var myWindow = window.open(url,"","");
It will open redirecting me to twitter so i can’t add any JS in the popup. I just can open the address. So i can’t use any JS in the popup to call parent window. am I right? Maybe I am wrong about this, I’m not great with JS.
What I did and it is working:
I set a timer with a function that is running every second.
In that function I check the popup URL, while I’m out of my domain i can’t but when the callBack URL is launched, the window come back to my domain I read de URL and if i can find the oauth_verifier as a field in the URL i close the popup and read the URL to recover the verifier.
var timer = setInterval(checkVentana, 1000);
function checkVentana() {
try {
var ur = myWindow.location.href;
if (ur.indexOf(‘oauth_verifier’) != -1){
var verifier = “”;
var token = “”;
clearInterval(timer);
myWindow.close();
ur = ur.substring(ur.indexOf(’?’)+1);
var urPartes = ur.split(’&’);
for (i = 0; i < urPartes.length; i++){
if (urPartes[i].indexOf(‘oauth_verifier’) != -1){
verifier = urPartes[i].split(’=’)[1];
}
if (urPartes[i].indexOf(‘oauth_token’) != -1){
token = urPartes[i].split(’=’)[1];
}
}
f.oauth_verifier.value = verifier;
f.oauth_token.value = token;
f.submit();
}
} catch (e){
}
}
the try/catch block it is to avoid JS errors for “myWindow.location.href” while I’m trying to access the URL while the popup it is out of my domain.
I know it is not a very good way to do it but i couldn’t find anything useful.