capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
398 stars 102 forks source link

feat: SignInWithGoogle AuthCredential accessToken undefined #54

Closed aliexalter closed 2 years ago

aliexalter commented 2 years ago

I am using

FirebaseAuthentication.signInWithGoogle()

Which return both User and AuthCredential. Under AuthCredential I am not getting oAuth access token. I am only getting providerId and idToken.

I would like to use oAuth access token to call REST API of google photo library (https://photoslibrary.googleapis.com/v1/albums). But When I console.log SignInResult.AuthCredential.accessToken its undefined.

How plugin chose its OIDC provider or OAuth provider. Can we set provider in this plugin ?

I test it on iOS device.

robingenz commented 2 years ago

Hi @aliexalter, thank you for your request. I will have a look at it. I think it should be possible to return the access token.

How plugin chose its OIDC provider or OAuth provider. Can we set provider in this plugin ?

The provider is chosen with the method you use for sign in (e.g. signInWithGoogle, signInWithFacebook, etc.).

aliexalter commented 2 years ago

@robingenz Thank you I hope this access token works with google photo library REST API.

robingenz commented 2 years ago

Do you also need it on Android? On Android, unfortunately, the access token is not provided and I would have to expose a server auth token instead, which you would have to swap server-side for a google access token.

aliexalter commented 2 years ago

Yes that will be great.

robingenz commented 2 years ago

@aliexalter Feel free to test the new dev version and let me know if it works:

npm i @capacitor-firebase/authentication@0.2.0-dev.eeac0a7.1648649641
aliexalter commented 2 years ago

on iOS

Screenshot 2022-03-30 at 8 42 05 PM

on Adnroid

Screenshot 2022-03-30 at 8 43 45 PM
robingenz commented 2 years ago

Fixed. Should work now:

npm i @capacitor-firebase/authentication@0.2.0-dev.1e9823b.1648714344
aliexalter commented 2 years ago

Thanks it's working great on iOS.

robingenz commented 2 years ago

Have you only tested iOS or does Android still not work?

aliexalter commented 2 years ago

I only tested on iOS. On android I don't need access token to get google API as we already on google platform so we use sharing and camera plugin to access google drive and photos.