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

Facebook requiring https on oauth callback #343

Open
ryan-wong opened this issue Oct 15, 2018 · 4 comments
Open

Facebook requiring https on oauth callback #343

ryan-wong opened this issue Oct 15, 2018 · 4 comments

Comments

@ryan-wong
Copy link

This is facebook statement:

Earlier this year, we announced that we are requiring Facebook Login redirects to use HTTPS, and all Facebook JavaScript SDK calls that return or require an access token to occur only from HTTPS pages. HTTPS helps keep transmitted information private and helps protect the security of people using your site and Facebook Login. Additionally, “Enforce HTTPS” has been a requirement for Facebook Login for new apps created since March 2018. | Earlier this year, we announced that we are requiring Facebook Login redirects to use HTTPS, and all Facebook JavaScript SDK calls that return or require an access token to occur only from HTTPS pages. HTTPS helps keep transmitted information private and helps protect the security of people using your site and Facebook Login. Additionally, “Enforce HTTPS” has been a requirement for Facebook Login for new apps created since March 2018.

Earlier this year, we announced that we are requiring Facebook Login redirects to use HTTPS, and all Facebook JavaScript SDK calls that return or require an access token to occur only from HTTPS pages. HTTPS helps keep transmitted information private and helps protect the security of people using your site and Facebook Login. Additionally, “Enforce HTTPS” has been a requirement for Facebook Login for new apps created since March 2018.

So what can we change in library to accommodate for this? I can't add an SSL certificate since its a hybrid app not website.

@z--z---z-----
Copy link

I have analyzed the **function oauthFacebook(clientId, appScope, options) ** in oauth.facebook.js and got to the conclusion that just passing {redirect_uri: "https://localhost/callback"} in the options paramenter should make the call work (note the https). And it did.
I am not sure if there is an side effect I can't see here, but this is how I got to the conclusion:

  1. The library builds an address like this (note I have hidden the client id, adding XxXx...):
    https://www.facebook.com/v2.6/dialog/oauth?client_id=XxXxXxXxXxXx&redirect_uri=https://localhost/callback&response_type=token&scope=email,public_profile,user_friends

  2. Facebook is rejecting the call if redirect_uri is not https, but now I have added an https address.

  3. Facebook process our request and will redirect to the address we specified with some parameters as response. Here is one response(note token is hidden:ToToTo):
    https://localhost/callback#access_token=ToToToTo&expires_in=6542&reauthorize_required_in=7776000&data_access_expiration_time=1549480258

  4. Looking into the library code:
    browserRef.addEventListener('loadstart', function(event) {
    if((event.url).indexOf(redirect_uri) === 0) {
    browserRef.removeEventListener("exit",function(event){});
    browserRef.close();
    var callbackResponse = (event.url).split("#")[1];
    var responseParameters = (callbackResponse).split("&");
    var parameterMap = [];
    for(var i = 0; i < responseParameters.length; i++) {
    parameterMap[responseParameters[i].split("=")[0]] = responseParameters[i].split("=")[1];
    }
    It will just process the url that Facebook redirected us to and will pick up the response data. So it doesn't matter what the redirect_uri is, the page never opens, but the url gets processed.

There is a "requirement" in the library documentation that tells the redirect uri must be http://localhost/callback, which I don't understand, it does not appear to be a must.

@alexislg2
Copy link

Thank you. I solved the HTTPS issue by calling the facebook login like that:

return $cordovaOauth.facebook(
    settings.FACEBOOK_ID,
    ['email',],
    {
        redirect_uri:'https://localhost/callback'
    },
).then(onSuccess, onError);

I don't understand why this is not the default behavior. Why are we only the 2 of us to be concerned by this issue?

@prafull-agarwal
Copy link

Adding
<allow-navigation href="http://localhost:8080/*"/>
in config.xml works for me.

@ciekawy
Copy link

ciekawy commented May 16, 2019

I think not much can be done really here - for the latest ionic 4 what works for me is:
ionic serve --ssl --cordova --platform browser

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

5 participants