GithubHelp home page GithubHelp logo

Comments (15)

carsonsuite avatar carsonsuite commented on May 18, 2024 1

@robingenz I hope exams are going well. What is the estimated lead time on resolving this?

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

Hi @ssibrahimbas,
thank you for your request.
This ID is IDP-specific user data and does not have to be present. According to Firebase Docs the type on Android of getProfile() is abstract Map<String, Object>.
For that reason I wouldn't focus on the ID but instead try to make the whole map available.
The ID would then be contained there.
This would definitely be a useful feature.

from capacitor-firebase.

jwt02180 avatar jwt02180 commented on May 18, 2024

I'd like to add my own interest in being able to retrieve AdditionalUserInfo.
My use case is to determine whether someone that has logged in is a new user or not (by checking isNewUser).
This would be useful for several reasons, but the first thing that came to mind was triggering an appropriate analytics event (sign_up vs login).

Just taking the web implementation of this plugin for a google sign-in as an example, the signInWithPopup result is not exposed for us to use (which resolves with the required UserCredential).

Following your example for using the JS SDK here is too late since the signInWithCredential (which resolves with the required UserCredential) is technically a second login and thus will always return false for isNewUser.

from capacitor-firebase.

typefox09 avatar typefox09 commented on May 18, 2024

Is there any update on this feature?

This has become a problem for Apple login now as Apple is refusing apps that don't make use of the fullName data they provide to us, to pre-fill in user fields.

Issue is that Apple doesn't return the users name in the idToken, instead it's available through the appleIDCredential.fullName field (only given the first time the user authorises your app).

If we could expose AddtionalUserInfo (on iOS & Android), then this name field could be passed back to the web view to update the user instance there.

Refer to this issue for full reference to the issue (still ongoing):
firebase/firebase-ios-sdk#4393

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

Is there any update on this feature?

This has become a problem for Apple login now as Apple is refusing apps that don't make use of the fullName data they provide to us, to pre-fill in user fields.

Issue is that Apple doesn't return the users name in the idToken, instead it's available through the appleIDCredential.fullName field (only given the first time the user authorises your app).

If we could expose AddtionalUserInfo (on iOS & Android), then this name field could be passed back to the web view to update the user instance there.

Refer to this issue for full reference to the issue (still ongoing): firebase/firebase-ios-sdk#4393

@ssibrahimbas currently working on that (see #81).

However, you should already have access to the name of the user (see displayName in https://github.com/robingenz/capacitor-firebase/tree/main/packages/authentication#user).

from capacitor-firebase.

typefox09 avatar typefox09 commented on May 18, 2024

Is there any update on this feature?
This has become a problem for Apple login now as Apple is refusing apps that don't make use of the fullName data they provide to us, to pre-fill in user fields.
Issue is that Apple doesn't return the users name in the idToken, instead it's available through the appleIDCredential.fullName field (only given the first time the user authorises your app).
If we could expose AddtionalUserInfo (on iOS & Android), then this name field could be passed back to the web view to update the user instance there.
Refer to this issue for full reference to the issue (still ongoing): firebase/firebase-ios-sdk#4393

@ssibrahimbas currently working on that (see #81).

However, you should already have access to the name of the user (see displayName in https://github.com/robingenz/capacitor-firebase/tree/main/packages/authentication#user).

The User object with displayName doesn't come through as we are skipping native auth (you have to for Apple sign in anyway). As per the Github issue I mentioned, Firebase is not saving the displayName either way.

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

you have to for Apple sign in anyway

What du you mean exactly? You do not have to set skipNativeAuth to true to use Apple Sign-In.

from capacitor-firebase.

typefox09 avatar typefox09 commented on May 18, 2024

you have to for Apple sign in anyway

What du you mean exactly? You do not have to set skipNativeAuth to true to use Apple Sign-In.

Sorry I should have elaborated further, technically it's not a requirement. What I meant to say is if you want to sign in on the web view, you need to have skipNativeAuth to false, otherwise the web sign in fails as the nonce has already been used.

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

Okay, now I understand the problem. I prioritize the issue.

from capacitor-firebase.

fryiee avatar fryiee commented on May 18, 2024

@robingenz any update on this one?

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

No, not yet. I will try to look into this issue next week. I am currently writing my exams and therefore do not have much time.

from capacitor-firebase.

fryiee avatar fryiee commented on May 18, 2024

Thank you for the update. Good luck with your exams!

from capacitor-firebase.

typefox09 avatar typefox09 commented on May 18, 2024

For reference I have added the code for the main function that I had to modify for the Apple auth. I'm not a Swift developer so please excuse any bad code.

It's important to note that Apple will only give the name on the very first attempt of that user authorising your app, any subsequent requests do not include the name field. If you need to test this I recommend visiting https://appleid.apple.com/ after each sign in, you can deauthorise your application there for a fresh sign in attempt.

func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
    guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential else {
        return
    }
    guard let nonce = currentNonce else {
        fatalError("Invalid state: A login callback was received, but no login request was sent.")
    }
    guard let appleIDToken = appleIDCredential.identityToken else {
        print("Unable to fetch identity token")
        return
    }
    guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else {
        print("Unable to serialize token string from data: \(appleIDToken.debugDescription)")
        return
    }
    var displayName: String?
    if let fullName = appleIDCredential.fullName {
        if let givenName = fullName.givenName, let familyName = fullName.familyName {
            displayName = "\(givenName) \(familyName)"
        }
    }
    let credential = OAuthProvider.credential(withProviderID: "apple.com", idToken: idTokenString, rawNonce: nonce)
    self.pluginImplementation.handleSuccessfulSignIn(credential: credential, idToken: idTokenString, nonce: nonce, accessToken: nil, additionalUserInfo: displayName)
}

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

ETA is 2 weeks, I am unfortunately still busy, PRs are welcome

from capacitor-firebase.

robingenz avatar robingenz commented on May 18, 2024

You can now test the first dev version:

npm i @capacitor-firebase/[email protected]

Example to get the Google user ID (Android):

const result = await FirebaseAuthentication.signInWithGoogle();
const googleUserId = result?.additionalUserInfo?.profile?.sub;

@typefox09 Unfortunately your problem had nothing to do with AdditionalUserInfo, because the Apple DisplayName is not part of this interface (see Firebase docs). So for your problem I would like to try to find another solution first, before we extend interfaces with custom properties. I have created a new issue for this: #155

from capacitor-firebase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.