mk-5 / gdx-fireapp

libGDX Firebase API
Apache License 2.0
65 stars 21 forks source link

Feature Request Sign-In with Apple #48

Closed Trurl101 closed 1 year ago

Trurl101 commented 3 years ago

Is your feature request related to a problem? Please describe.

Describe the solution you'd like Something like the google sign-in: GdxFIRAuth.inst().google().signIn().then... for example: GdxFIRAuth.inst().apple().signIn().then...

It would make User Authentication on IOS much easier.

mk-5 commented 3 years ago

@Trurl101 sure, thanks for a request!

I'd try to bring it to gdx-fireapp next week

mk-5 commented 3 years ago

sorry for a delay. I was out for a while. I'll try to pick this topic soon.

Daniel-Donev commented 2 years ago

Hi, I try to implement Sign-In with Apple but when I change the library version to the latest 3.2.0 Gradle failed to resolve the dependency... Can you help me with this?

mk-5 commented 2 years ago

Hello @Daniel-Donev

sure, I need to check, and I'll let you know. There was indeed a problem with shutting down the jcenter() repo. It could be that artefact has not been successfully deployed to maven central.

Pls check if you have mavenCentral() in your repositories block

Daniel-Donev commented 2 years ago

Hi, the problem is still here... this is my repositories block

buildscript { repositories { mavenLocal() maven { url "https://plugins.gradle.org/m2/" } maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } jcenter() google() maven { url 'https://maven.google.com' } mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' classpath 'com.google.gms:google-services:4.3.4' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.10' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0' } }

allprojects { apply plugin: "eclipse" apply plugin: "idea"

version = '1.0'

repositories {
    mavenLocal()
    jcenter()
    google()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    mavenCentral()
}

}

Daniel-Donev commented 2 years ago

Is it possible to download version 3.2.0 with Gradle or the problem is in the maven version?

https://search.maven.org/search?q=g:pl.mk5.gdx-fireapp

mk-5 commented 2 years ago

@Daniel-Donev I need to check, it's just not deployed into maven-central correctly.

btw, I think you can remove jcenter() from your repositories. https://blog.gradle.org/jcenter-shutdown

Daniel-Donev commented 2 years ago

Thank you!

mk-5 commented 2 years ago

@Daniel-Donev pls re-check, version should be there

Daniel-Donev commented 2 years ago

All good.

Thanks for the great work!

Today I will try to implement the Apple Sign-In.

Daniel-Donev commented 2 years ago

when I include iosEntitlementsPList in my robovm.xml like this:

data/Entitlements.plist Info.plist.xml

I run into this error: [ERROR] Couldn't start application org.robovm.libimobiledevice.LibIMobileDeviceException: ApplicationVerificationFailed at org.robovm.libimobiledevice.util.AppLauncher$1.error(AppLauncher.java:1006) at org.robovm.libimobiledevice.Callbacks.callInstproxyCallback(Callbacks.java:64)

My Entitlements.plist is like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd%22%3E
<plist version="1.0">
<dict>
    <key>com.apple.security.get-task-allow</key>
    <true/>
    <key>com.apple.developer.applesignin</key>
    <array>
        <string>Default</string>
    </array>
</dict>
</plist>

EDIT: with :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd%22%3E
<plist version="1.0">
<dict>
    <key>com.apple.developer.applesignin</key>
    <array>
        <string>Default</string>
    </array>
</dict>
</plist>

all fine... It is important for production?

Daniel-Donev commented 2 years ago

@mk-5 Hi, today I'have tried the apple sign in implementation on iPhone 7 with iOS 15 and everything was ok (the sign in popped up asking for password) until after I have entered my pass I get this error: "Unable to parse the ID Token." It dosen create authentication user in firebase. I believe that this is something from the library? What do you think?

mk-5 commented 2 years ago

@Daniel-Donev can you give me a full stacktrace? or at least some part?

Daniel-Donev commented 2 years ago

Hi @mk-5 I didn't have a crash error, just catch this from .fail()

GdxFIRAuth.inst().apple().signIn().then(new Consumer<GdxFirebaseUser>() {
                @Override
                public void accept(GdxFirebaseUser user) {
                    logged.user = user;
                }
            }).fail(new BiConsumer<String, Throwable>() {
                @Override
                public void accept(String s, Throwable throwable) {
                    println("firebase error: " + s); // this line print "firebase error: Unable to parse the ID Token."
                }
            });
mk-5 commented 2 years ago

Yes, you have throwable there. You can print the stack trace :)

throwable.printStackTrace();

On Wed, Oct 20, 2021, at 07:46, Daniel-Donev wrote:

Hi @mk-5 https://github.com/mk-5 I didn't have a crash error, just catch this from .fail

GdxFIRAuth.inst().apple().signIn().then(new Consumer<GdxFirebaseUser>() { @Override public void accept(GdxFirebaseUser user) { logged.user = user; } }).fail(new BiConsumer<String, Throwable>() { @Override public void accept(String s, Throwable throwable) { println("firebase error: " + s); // return "firebase error: Unable to parse the ID Token." } });

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mk-5/gdx-fireapp/issues/48#issuecomment-947347712, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHTADFCNQME2CLWSOYVB4OLUHZJTXANCNFSM4YO5G5AA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Pozdrawiam, Mateusz Kulawik

Daniel-Donev commented 2 years ago

Hi @mk-5, sorry for the delay I was sick...

the throwable.printStackTrace(); return

java.lang.RuntimeException: Unable to parse the ID Token. at pl.mk5.gdx.fireapp.ios.auth.AppleAuthProvider$1.invoke(AppleAuthProvider.java:54) at pl.mk5.gdx.fireapp.ios.auth.AppleAuthProvider$1.invoke(AppleAuthProvider.java:50) at org.robovm.pods.firebase.auth.FIRAuth$$BlockMarshaler2.invoked(Unknown Source) at org.robovm.apple.uikit.UIApplication.main(Native Method) at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:446) at com.playshiftboy.IOSLauncher.main(IOSLauncher.java:61)

can you help me?

Daniel-Donev commented 2 years ago

Where do you think is the problem? Can I track anything else to help you?

mk-5 commented 2 years ago

@Daniel-Donev mhmm I need to investigate. Unable to parse the ID Token. is nothing comming from our lib.

The error is comming from FIRAuth.auth().signInUsingCredential execution. The execution is here: https://github.com/mk-5/gdx-fireapp/blob/master/gdx-fireapp-ios/src/pl/mk5/gdx/fireapp/ios/auth/AppleAuthProvider.java line 54

Daniel-Donev commented 2 years ago

Hi @mk-5, I implement all steps from https://github.com/mk-5/gdx-fireapp/wiki/iOS-Guide and FIRAuth I think is from download required frameworks. I don't have any problems with Google Sign in.

If I need to update some of the required frameworks or its something else?

Thanks for the support

Daniel-Donev commented 2 years ago

Hi, @mk-5 sorry to bother you again. I just wanted to ask did you had the time to look into the problem?

mk-5 commented 2 years ago

@Daniel-Donev hi hi, no problem. I was out for a short period of time.

mhmmm there is also additional step required in order to make apple sign-in works. It's described here: https://github.com/mk-5/gdx-fireapp/wiki/Apple-Sign-in

Daniel-Donev commented 2 years ago

Hi, @mk-5 I have implemented all of these steps since the beginning.

and I still have the problem:

java.lang.RuntimeException: Unable to parse the ID Token. at pl.mk5.gdx.fireapp.ios.auth.AppleAuthProvider$1.invoke(AppleAuthProvider.java:54) at pl.mk5.gdx.fireapp.ios.auth.AppleAuthProvider$1.invoke(AppleAuthProvider.java:50) at org.robovm.pods.firebase.auth.FIRAuth$$BlockMarshaler2.invoked(Unknown Source) at org.robovm.apple.uikit.UIApplication.main(Native Method) at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:446) at com.playshiftboy.IOSLauncher.main(IOSLauncher.java:61)

did you successfully try your implementation with apple sign-in?

where else do you think my mistake could be?

mk-5 commented 2 years ago

@Daniel-Donev yes, I'm able to run this test successfully: https://github.com/mk-5/gdx-fireapp/blob/master/e2e/core/src/pl/mk5/gdx/fireapp/e2e/tests/AuthAppleSignInTest.java

Daniel-Donev commented 2 years ago

Ok, thank you. I will check all the steps again.

mk-5 commented 2 years ago

@Daniel-Donev I just checked, look:

image

"Unable to parse the ID Token." we need to find what could be the reason for that. Do you have apple sign-in enabled in firebase console?

Daniel-Donev commented 2 years ago

Yeah, I think so... These days I will check all of my implementations and will share what I will find.

Thank you!

Daniel-Donev commented 2 years ago

Hi I still have the same problem :(

I have a configuration on my firebase for ios version and authentication with apple I configure my App in developer.apple.com to support "sign in with Apple" I implement all of your steps. Ios version successfully login with "google sign-in" and use firebase.

overall I have this error return: Domain=FIRAuthErrorDomain Code=17004 "Unable to parse the ID Token." UserInfo={NSLocalizedDescription=Unable to parse the ID Token., FIRAuthErrorUserInfoNameKey=ERROR_INVALID_CREDENTIAL}

but the credential.getEmail() is returning my apple email!

credential.getIdentityToken().toString() return {length = 870, bytes = 0x65794a72 61575169 4f694a6c 57474631 ... 76305771 56344d51 } nonce return bd35fb6eed1d9b4c17c21881f81e5e5390fa3a1ea5fe8f2a066346bcb578d575 and PROVIDER return apple.com

In my Entitlements.plist i remove:

com.apple.security.get-task-allow
<true/>

because I try to build a deployment version - can this be a problem?

Can you suggest to me what can do?

mk-5 commented 2 years ago

Mhmm, I will examinate the E2E test configuration, maybe I forgot about something in docs.

Now I’m „out-of-pc”, but I will try to look on it asap ;)

Daniel-Donev commented 2 years ago

Hi

Thank you for your help.

I downloaded your project and ran e3e the test.

I replaced GoogleService-Info.plist to work with our firebase and changed app.id in robovm.properties.

I had to replace "ios/libs/" I guess because of the difference in the PC architecture.

The other change I had was to remove this: " com.apple.security.get-task-allow "true />" from Entitlements.plist in order to upload the project to the phone.

It still gives me the same error: Domain=FIRAuthErrorDomain Code=17004 "Unable to parse the ID Token." UserInfo={NSLocalizedDescription=Unable to parse the ID Token., FIRAuthErrorUserInfoNameKey=ERROR_INVALID_CREDENTIAL}

Thanks in advance

mk-5 commented 2 years ago

@Daniel-Donev interesting ... mhmmm what do you mean by "I had to replace ios/libs/ beacuse of the difference in the PC architecture?

Daniel-Donev commented 2 years ago

Hi @mk-5 in your e3e the test project you have all libraries (frameworks) in ios/libs/ . the libraries (frameworks) in your folder didn't work in our environment and we downloaded them from here - https://firebase.google.com/download/ios and replaced them in the same folder.

mk-5 commented 2 years ago

@Daniel-Donev mhmm, for me it works. It really looks like some firebase-console configuration issue.

Have you seen this? https://stackoverflow.com/questions/56712711/login-through-facebook-using-oauth-issue-with-firebase-app-id-in-the-input-toke Guy got the same error, FIRAuthErrorDomain Code=17004

It's hard to say something, because I cannot see your firebase console. I would go through points here: https://firebase.google.com/docs/auth/ios/apple?authuser=0 and check if everything is configured.

In addition you can check Entitlements.plist. It should pointed-out in your robovm.xml. This is what I got for e2e project:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.get-task-allow</key>
    <true/>
    <key>com.apple.developer.applesignin</key>
    <array>
        <string>Default</string>
    </array>
</dict>
</plist>

If everything from that is correct on your side, maybe you can create some demo project, with demo firebase app / configure everything as you did, and send it to me via zip? then I will be able to really examinate it.

Daniel-Donev commented 2 years ago

Hi @mk-5

I try and test so many times my firebase-console configuration - console

and all off this points: https://firebase.google.com/docs/auth/ios/apple?authuser=0

user: Have an Apple ID with two-factor authentication (2FA) enabled. - true user: Be signed in to iCloud on an Apple device. - true app bundle ID needs to match with bundle id configured in firebase console - true enable apple sign in in Firebase Console -> Authentication tab - true

Its is "com.apple.security.get-task-allow " important?

because I try to set it and my project can`t deploy on the iPhone and I removed...

Thank you for your help! I am a little sick at the moment, but I will make an archive as soon as possible.

Daniel-Donev commented 2 years ago

Hi @mk-5 we send you an e-mail with demo project. Thank you for your help.

mk-5 commented 2 years ago

@Daniel-Donev all right, I'll check it as soon as I get it: git@mk5.pl

Daniel-Donev commented 2 years ago

@mk-5, just wondering did you get the email?

mk-5 commented 2 years ago

@Daniel-Donev nope, I didn't get anything

Daniel-Donev commented 2 years ago

@mk-5, we have resended the e-mail from another e-mail account - Magic box. If it`s not in you inbox please check the spam folder.

prateekchandan commented 1 year ago

@mk-5 @Daniel-Donev

I am also stuck at same issue since last month and tried all the things mentioned here and on firebase page for setting up apple login.

but stuck at errror:

java.lang.RuntimeException: Unable to parse the ID Token.
    at pl.mk5.gdx.fireapp.ios.auth.AppleAuthProvider$1.invoke(AppleAuthProvider.java:54)
    at pl.mk5.gdx.fireapp.ios.auth.AppleAuthProvider$1.invoke(AppleAuthProvider.java:50)
    at org.robovm.pods.firebase.auth.FIRAuth$$BlockMarshaler2.invoked(Unknown Source)
    at org.robovm.apple.uikit.UIApplication.main(Native Method)
    at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:433)
    at com.dalmalgames.IOSLauncher.main(IOSLauncher.java:37

Did you figure something out ?

Daniel-Donev commented 1 year ago

@prateekchandan @mk-5 Unfortunately, I also can't resolve the issue with "Unable to parse the ID Token"

I repeatedly tried to integrate "Sign-In with Apple" as described without success.

I will follow with interest if there is any development on the subject. If you find some solution or integrate successfully, I will know that there is no problem with the integration.

prateekchandan commented 1 year ago

I have fixed this issue and created a pull request : https://github.com/mk-5/gdx-fireapp/pull/64

@mk-5 Can you validate and merge

mk-5 commented 1 year ago

@prateekchandan let me run e2e tests / and I will merge it right away. Awesome! 🍻

mk-5 commented 1 year ago

@prateekchandan I fixed two small fixes directly in master 🙈 as I mentioned in a PR comment - for any reasons pipelines has been not triggered, and there were some syntax issues in the code.

https://github.com/mk-5/gdx-fireapp/commit/e3d64b7c7aeb8b9abb34357e06a02fd70bc39b3d

https://github.com/mk-5/gdx-fireapp/commit/d93904a5d6d048b5e485c7507ebf47517f490b28

Let me verify master after those changes, and I will release a new version

mk-5 commented 1 year ago

okay, so local e2e tests works

image

but there were fine for me previosuly as well. I will release a new version 3.3.1 - @Daniel-Donev @prateekchandan pls verify if the latest fix works

Daniel-Donev commented 1 year ago

Awesome!

I will need time to re-integrate "Sign-In with Apple" as described. Then I will give feedback.

prateekchandan commented 1 year ago

It works for me, and launched the multiplayer version of my game here. https://apps.apple.com/us/app/classic-callbreak/id6444685243 :D

prateekchandan commented 1 year ago

@mk-5 Please feel free to close this issue.

mk-5 commented 1 year ago

@prateekchandan awesome :)