Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After login it's redirect me to the "redirect_url" #23

Open
sameh-serag opened this issue Jul 4, 2016 · 4 comments
Open

After login it's redirect me to the "redirect_url" #23

sameh-serag opened this issue Jul 4, 2016 · 4 comments

Comments

@sameh-serag
Copy link

i tried your example.
function oauth2_login() {
$.oauth2({
auth_url: 'https://www.facebook.com/dialog/oauth',
response_type: 'token',
client_id: 'XXXXXXXXXXX',
redirect_uri: 'http://www.zonnix.net',
other_params: {}
}, function(token, response){
// makeAPICalls(token);
return;
}, function(error, response){
console.log(error);
return;
});

when i tried it in the emulator ... after successful login the page redirected to the "redirect_url"
Please could u tell me how to avoid the redirect. The facebook force me to insert "redirect_url" related to my valid domain

@blokeish
Copy link

Yes, with cordova you don't want to be redirected to an external page but return to your app. How can this be done?

@krisrak
Copy link
Owner

krisrak commented Sep 14, 2016

@blokeish This plugin is not opening external web browser window, it is opening a webview within the app, so when redirect happens it just closes the webview modal view. Its always in the app.

@sameh-serag you can just put your domain url for redirect url, its not really using it, just grabbing url-param, so does not matter contents of the page

@blokeish
Copy link

Thanks krisrak, that make sense. I will try it out and see how it goes..

@joshuaquek
Copy link

joshuaquek commented Apr 23, 2017

Ok, I figured a solution to this.

Firstly, the latest version of Cordova's InAppBrowser doesn't use
window.open anymore.

The fix would be to change line 85 inside cordova.oauth2.js
from:
var loginWindow = window.open(login_url, '_blank', 'location=yes,clearsessioncache=yes');

to

var loginWindow = cordova.InAppBrowser.open(login_url, '_blank', 'location=yes,clearsessioncache=yes');

This should fix the issue.

Also, remember to import in InAppBrowser to your project:
cordova plugin add cordova-plugin-inappbrowser

and also, remember to include cordova.js inside your tag:

<head>
  <script type="text/javascript" src="cordova.js"></script>
  <script type="text/javascript" src="css/jquery.min.js"></script>
  <script type="text/javascript" src="css/cordova.oauth2.js"></script>
</head>

This was the solution that worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants