gdx-fireapp icon indicating copy to clipboard operation
gdx-fireapp copied to clipboard

Feature Request Sign-In with Apple

Open Trurl101 opened this issue 4 years ago • 38 comments

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

  • Firebase "Sign-In with Apple"

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.

Trurl101 avatar Mar 02 '21 12:03 Trurl101

@Trurl101 sure, thanks for a request!

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

mk-5 avatar Mar 02 '21 20:03 mk-5

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

mk-5 avatar May 22 '21 16:05 mk-5

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?

Daniel-Donev avatar Sep 22 '21 08:09 Daniel-Donev

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

mk-5 avatar Sep 22 '21 18:09 mk-5

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 avatar Sep 25 '21 07:09 Daniel-Donev

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

Daniel-Donev avatar Sep 28 '21 18:09 Daniel-Donev

@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

mk-5 avatar Oct 04 '21 20:10 mk-5

Thank you!

Daniel-Donev avatar Oct 06 '21 18:10 Daniel-Donev

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

mk-5 avatar Oct 14 '21 20:10 mk-5

All good.

Thanks for the great work!

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

Daniel-Donev avatar Oct 15 '21 09:10 Daniel-Donev

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

<iosEntitlementsPList>data/Entitlements.plist</iosEntitlementsPList> <iosInfoPList>Info.plist.xml</iosInfoPList>

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 avatar Oct 15 '21 18:10 Daniel-Donev

@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?

Daniel-Donev avatar Oct 16 '21 14:10 Daniel-Donev

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

mk-5 avatar Oct 19 '21 20:10 mk-5

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."
                }
            });

Daniel-Donev avatar Oct 20 '21 05:10 Daniel-Donev

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

mk-5 avatar Oct 20 '21 20:10 mk-5

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 avatar Nov 13 '21 09:11 Daniel-Donev

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

Daniel-Donev avatar Nov 19 '21 10:11 Daniel-Donev

@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

mk-5 avatar Nov 23 '21 20:11 mk-5

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 avatar Nov 24 '21 06:11 Daniel-Donev

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

Daniel-Donev avatar Dec 04 '21 10:12 Daniel-Donev

@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

mk-5 avatar Dec 04 '21 20:12 mk-5

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?

Daniel-Donev avatar Dec 04 '21 21:12 Daniel-Donev

@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

mk-5 avatar Dec 04 '21 21:12 mk-5

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

Daniel-Donev avatar Dec 04 '21 21:12 Daniel-Donev

@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?

mk-5 avatar Dec 04 '21 21:12 mk-5

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

Thank you!

Daniel-Donev avatar Dec 04 '21 21:12 Daniel-Donev

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 because I try to build a deployment version - can this be a problem?

Can you suggest to me what can do?

Daniel-Donev avatar Jan 08 '22 12:01 Daniel-Donev

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 ;)

mk-5 avatar Jan 15 '22 19:01 mk-5

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

Daniel-Donev avatar Jan 17 '22 16:01 Daniel-Donev

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

mk-5 avatar Jan 25 '22 21:01 mk-5

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.

Daniel-Donev avatar Jan 25 '22 21:01 Daniel-Donev

@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.

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

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.

mk-5 avatar Jan 27 '22 21:01 mk-5

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 avatar Jan 28 '22 07:01 Daniel-Donev

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

Daniel-Donev avatar Jan 29 '22 10:01 Daniel-Donev

@Daniel-Donev all right, I'll check it as soon as I get it: [email protected]

mk-5 avatar Jan 29 '22 17:01 mk-5

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

Daniel-Donev avatar Feb 01 '22 08:02 Daniel-Donev

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

mk-5 avatar Feb 09 '22 20:02 mk-5

@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.

Daniel-Donev avatar Feb 12 '22 09:02 Daniel-Donev