[AC-4955] Webview Google OAuth Issue
GitHub Issue | n/a |
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Not Our Bug |
Resolution Date | 2017-05-10T11:22:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | JATIN JOSHI |
Assignee | Shak Hossain |
Created | 2017-05-09T23:55:49.000+0000 |
Updated | 2017-05-10T13:28:28.000+0000 |
Description
I am using the OAuth feature of Google to authenticate users. Authorization page opens with a 403 error with the description:
This user-agent is not permitted to make OAuth authorization request to Google as it is classified as an embedded user-agent (also known as a web-view). Per our policy, only browsers are permitted to make authorization requests to Google. We offer several libraries and samples for native apps to perform authorization request in browser.
Google url is opened within web view.
Code Snippet:
$.webview.url = args.url;//for new oAuth
function webviewLoaded(e){
//wait for result to be put on webview by backend:
var result = $.webview.evalJS('result');
console.log("Social Login Results ---" + result);
//when get the result, call the return function in index.js and return the result:
if(result){
args.loginReturned(result);
$.socialLogin.close();
}
}
Attachments
Here are your options (this is no Titanium issue): - Use the [Ti.GoogleSignIn](https://github.com/hansemannn/titanium-google-signin) module to do the OAuth flow with their native library - Use the Safari-Browser via
Ti.Platform.openURL
to handle the URL and set the callback url-scheme to your app's URL scheme (e.g.myapp://
WebViews in general are disallowed by Google, that's what the message also says. I hope one of the above suggestions will help.I tried this: safariDialog.open({ url: args.url, tintColor:"red" }); Ti.App.iOS.addEventListener("handleurl", function(e) { // If the handled url is provided by the safari-dialog, close it (use-case for OAuth) console.log("RESPONSE FROM SERVER" + JSON.stringify(e)); if (e.launchOptions.source == "com.apple.SafariViewService") { safari.close(); } }); But not getting any response.