- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am a newbie for intel xdk and coding as whole. I am working on Oauth2 . I am using the response type as Token. I am able to generate the redirect URI with auth token. When I call the google appscript webapp appended by the auth token, it works in emulator (sometimes). For this I call a function and pass webapp url along with auth token. Then I use command window.open(URL) to open the webapp. However, this do not work when "Test" or Debug mode and the script stops at the redirect uri page. Thus I understand that token is generated but the webapp is not getting called. Please help how to fix it.
- Tags:
- HTML5
- Intel® XDK
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Would it be possible for you to attach an example XDK project that shows the problem? Or post the relevant code? That would help us figure out what's going on. Also you may want to look at this article, though it might be a bit out of date.
Dale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dale,m.
Really, really glad to hear back from you. Sorry had forgotten to add code earlier. PFB. Would really appreciate if you can help solve my problem.
<!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="xhr.js"></script> <script src="intelxdk.js"> </script> <script> var OAUTHURL = 'https://accounts.google.com/o/oauth2/auth?'; var VALIDURL = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='; var SCOPE = 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email'; var CLIENTID = '**************************************'; var REDIRECT = 'http://example.com/oauth2callback' var LOGOUT = 'http://accounts.google.com/Logout'; var TYPE = 'token'; var _url = OAUTHURL + 'scope=' + SCOPE + '&client_id=' + CLIENTID + '&redirect_uri=' + REDIRECT + '&response_type=' + TYPE; var acToken; var tokenType; var expiresIn; var user; var loggedIn = false; function login() { var win = window.open(_url); var pollTimer = window.setInterval(function() { try { console.log(win.document.URL); if (win.document.URL.indexOf(REDIRECT) != -1) { window.clearInterval(pollTimer); var url = win.document.URL; acToken = gup(url, 'access_token'); tokenType = gup(url, 'token_type'); expiresIn = gup(url, 'expires_in'); getUserInfo(acToken); } } catch(e) { ;} }, 500); } function gup(url, name) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\#&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( url ); if( results == null ) return ""; else return results[1]; } function getUserInfo() { var url_token= 'https://script.google.com/macros/s/************************************/exec?access_token=' + acToken; window.open(url_token); } </script> </head> <body> <a href='#' onClick='login(); id="loginText"'> Click here to login </a> <div id='uName'></div> <img src='' id='imgHolder'/> </body> </html>
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page