blakgeek / cordova-plugin-firebase-auth-google

Provides support for native login via Firebase providers
13 stars 13 forks source link

How do I use it? #2

Closed alxanthony closed 7 years ago

alxanthony commented 7 years ago

Hello, do you have sample code on how to use this? sorry but I couldn't figure it out

JohnMcAvinue commented 7 years ago

Yeah some instructions would be great. You've done all this work so it would be great to be able to use it!

alxanthony commented 7 years ago

@JohnMcAvinue Hey John, I wasn't able to make this work and looked for days and apparently is not supported I end up using auth0.com to provide the login process. I used angular as a framework and I can share with you my code if you want to take a look.

JohnMcAvinue commented 7 years ago

Hi @alxanthony thanks for replying and letting me know. It's funny that you mentioned Auth0 as I'm actually on that page now. Does it use the InAppBrowser or does it try to use the native app on the phone and fallback to InAppBrowser if it's not installed?

alxanthony commented 7 years ago

It uses inAppBrowser

siliconxp commented 7 years ago

Hi Blakgeek, great work here. Has this issue been close? I would also like to know how to use it.

blakgeek commented 7 years ago

This was orginally created for internal use. I'll add the documentation this weekend.

On Feb 9, 2017 6:58 PM, "Samson Muchindika" notifications@github.com wrote:

Hi Blakgeek, great work here. Has this issue been close? I would also like to know how to use it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/blakgeek/cordova-plugin-firebase-auth-google/issues/2#issuecomment-278815815, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyU3j2jZjbpVPLgNXeXjkh8BH85UUMLks5ra6gVgaJpZM4K6hCq .

thedmeyer commented 7 years ago

Is the documentation ready?

azumbrunnen commented 7 years ago

how can we use this?

cuduy197 commented 7 years ago

Still no docmument :(

phyr0s commented 7 years ago

any docs?

cuduy197 commented 7 years ago

NOW YOU CAN LOGIN GOOGLE IN CORDOVA USING FIREBASE AUTH, CHECK BELOW : https://firebase.google.com/docs/auth/web/cordova

happy coding :smiley:

Minimal88 commented 7 years ago

@alxanthony does the login with in auth0 is still working? after the block of google in all inAppBrowsers authentication in april 2017? I do implement it, and works fine in browser, but running in a mobile device (android), I get an 403 Error with this link in description: https://developers.googleblog.com/2016/08/modernizing-oauth-interactions-in-native-apps.html

alxanthony commented 7 years ago

@Minimal88 So I used a hack to trick google that is coming from a different browser agent. I havent had any problems with google login so far. my app still working and published on apple since november.

this is what I did: add this to your config.xml. It prevents Google from detecting the request is from a mobile app. It worked for me.

screen shot 2017-07-05 at 11 54 47 am

dont judge me :)

alxanthony commented 7 years ago

@Minimal88 For some reason github hides my xml code so I put it on a picture.

Minimal88 commented 7 years ago

@alxanthony wow thanks a lot!! that just save like a week of work! i just put it on android and works fine. I'm gona try in iOS. Just another question, are you using the last version of auth0-lock?

Because i was following these instructions (which they already remove), since I'm using firebase database for auth: https://auth0.com/docs/tutorials/using-ionic-and-firebase

and got an issue, that i solved bower installing auth0-lock#9.2.2 https://github.com/auth0/auth0-angular/issues/325

But then I implement the last (official) instructions: https://auth0.com/docs/quickstart/native/ionic/01-login

And everything works, but firebase do not accept me, the idtoken returned from authResult.

In the old version i get the token by:

     auth.getToken({
        api: 'firebase'
      })

Thanks again

alxanthony commented 7 years ago

@Minimal88 I dont remember what version Im using bue there is my google angular function if it helps you, I know Im using autho.js just not sure what version:

$scope.google = function(){ var auth0 = new Auth0({ domain: 'repps.auth0.com', clientID: 'LALALALA123LALALA', callbackURL: location.href, responseType: 'token' });

    auth0.login({
        connection: 'google-oauth2',
        popup: true,
        api: 'firebase',
        popupOptions: {
            width: 450,
            height: 800
        }
    }, function(err, result) {

        if (err) {
            console.log("something went wrong: " + err.message);
            return;
        }

        var options = {
            id_token: result.idToken,
            api: 'firebase'
        };

        auth0.getDelegationToken(options, function (err, delegationResult) {
            $scope.authObj.$signInWithCustomToken(delegationResult.id_token)
                .then(function(firebaseUser) {
                    $location.path('/index');
                }).catch(function(error) {
                    console.error("Error: ", error);
                });
        });
    });

};
blakgeek commented 7 years ago

Docs now exist.