Hi, I understand that Parse Server has been updated with native support for Apple Sign In, though I'm very uncertain what's recommended to implement it with this SDK. Should I write a helper that conforms to PFUserAuthenticationDelegate, similar to what the SDK has in PFFacebookUtils, or is that overkill?
PFFacebookUtils calls [FBSDKAccessToken setCurrentAccessToken: token] but idk what the equivalent would be for Apple.
Perhaps this information would be helpful to include in the SDK docs!
I think we ideally want a function like PFFacebookUtils' logInInBackgroundWithReadPermissions: which magically handles _both_ user login and signup.
So far I have:
// User clicked "sign in with apple" button
-(void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)){
NSLog(@"Authorized with %@: %@", authorization.provider, authorization.credential);
[User registerAuthenticationDelegate:self forAuthType:@"apple-signin"];
// TODO: acquire & format the `authData` json
[[User logInWithAuthTypeInBackground:@"apple-signin" authData:authData]
}
- (BOOL)restoreAuthenticationWithAuthData:(nullable NSDictionary<NSString *,NSString *> *)authData {
// TODO: Set current access token (I'm not sure this is possible or useful with Apple Sign In)
return YES;
}
The authData JSON eludes me. I thought this was a simple matter of deserializing the identityToken (which is a JWT) from the ASAuthorizationAppleIDCredential, but it's an NSData object which, when I use NSJSONSerialization on, results in a parsing error.
@tealshift have you looked into this any further? We're going to need that feature soon, and it would be really great if you could help. Apple apparently plans to disallow apps to use FB / Twitter login buttons without offering theirs after iOS 13 comes out.
You're looking down the right path with an implementation conforming to PFUserAuthenticationDelegate, in the same way the FB authenticator works. That's exactly how this needs to be done.
@drdaz I'm not at my office today, but I think the authData is going to be formatted like so:
///--------------------------------------
#pragma mark - ASAuthorizationControllerDelegate
///--------------------------------------
-(void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)){
ASAuthorizationAppleIDCredential *creds = authorization.credential;
NSString *idToken = [[NSString alloc]initWithData:creds.identityToken encoding:NSUTF8StringEncoding];
NSDictionary *authData = @{
@"id": creds.user,
@"token": idToken
};
[User logInWithAuthTypeInBackground:@"apple" authData:authData];
}
And I honestly don't remember where I got the @"apple-signin" identifier from. According to https://docs.parseplatform.org/parse-server/guide/#apple-authdata it should just be @"apple".
@tealshift I am looking forward for this but I don't have skill to contribute. Hope you are implementing this.
Thanks
Ashish
Just in case anyone is not aware, although helper methods could make using Apple sign more clean it should be possible with the existing linkWithAuthProvider methods.
I think @TomWFox is right. By the way, I think this would make a great update for ParseUI too since apples UI guidelines on this is pretty strict.
I'm not working on this at the moment, so I don't have anything to show besides an object that implements PFUserAuthenticationDelegate, ASAuthorizationControllerDelegate and contains the code I posted. I may be able to work on this later.
I was also indicating ParseUI. I am using Facebook and Twitter sign-in currently using ParseUI. Since Apple is mandating SIgn in with Apple, it would be good if ParseUI has this feature.
Apple is mandating Apple Sign In?! Thats for real? The only guideline I heard about the issue was that if you use Apple Sign In that they be the first option available UI-wise. So vertically they had to be above twitter and facebook or whatever.
So whats the mandate. If you offer 3rd Party sign in you also have to offer Apple Sign In. OR is it that you have to offer Apple Sign In even if you only allow user/pass login?
I believe you have to provide Sign In with Apple if you offer any other social sign in methods.
See parse-community/parse-server#5632
Nice! Thanks for the response @TomWFox! Doubt I would have found that issue on my own.
Hi, I'm trying to implement Sign in With Apple, the code for sign in I have so far is:
- (void)authorizationController:(ASAuthorizationController *)controller didCompleteWithAuthorization:(ASAuthorization *)authorization API_AVAILABLE(ios(13.0)) {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
ASAuthorizationAppleIDCredential *credential = authorization.credential;
NSString *convertedString = [[NSString alloc] initWithData:credential.identityToken encoding:NSUTF8StringEncoding];
[dict setObject:@"token" forKey:convertedString];
[dict setObject:@"id" forKey:credential.user];
[[PFUser logInWithAuthTypeInBackground:@"apple" authData:dict] continueWithBlock:^id _Nullable(BFTask<NSNumber *> * _Nonnull t) {
return t;
}];
}
and I keep getting
Parse server version is 3.9.0
I register authentication method during initialization
[PFUser registerAuthenticationDelegate:self forAuthType:@"apple"];
I don't know what I'm missing
forAuthType should be "apple-signin" based off what I see here.
https://github.com/parse-community/parse-server/pull/5694
When I rename it to that I get the error
This authentication method is unsupported. (Code: 252, Version: 1.17.3)
Interesting. Although I see that for 3.5. The guide clearly says apple. Have you checked the guide to make sure the server is setup correctly? https://docs.parseplatform.org/parse-server/guide/#apple-authdata
Yes, we've been using the server for a long time and have no problem logging in with Facebook
I wasnt suggesting that the server itself wasnt setup correctly. I was just making sure you had taken steps to add the config for apple sign in specifically.
This issue has been automatically marked as stale because it has not had recent activity. If you believe it should stay open, please let us know! As always, we encourage contributions, check out the Contributing Guide
Suggest this remains open.
This is a must have feature mandated by Apple on iOS so addition to the sdk will save many development hours across the developer community. Hence Requesting contributors to please implement it.
Please...
It's not manatory yet (IIRC they pushed back the requirement until some time in 2020), but I'll try and look at this at some point in the next couple of weeks.
Hi @drdaz,
Hope you will be adding this soon.
Thanks
Ashish
Hi @ashish-naik, whilst I appreciate this would be a useful feature - our contributors are volunteers and as such cannot implement every feature request & there have been more pressing issues for us to focus on lately.
Perhaps you would be willing to make a PR?
I understand that and appreciate great work by the volunteers but i don't have skills to do it myself.
Happy to wait till this gets prioritized.
Thanks,
Ashish
Hey, so does anybody know where we can get an official Apple logo to use on our sign in button?
Apple provides their own button for this purpose, but I suspect it might not match with our styling... and it definitely doesn't match with how the other login buttons have been implemented.
Do we just grab a random free one off the net and cross our fingers? 😬
Might be able to find one here - https://developer.apple.com/app-store/marketing/guidelines/
Perhaps chop it from these badges - https://developer.apple.com/app-store/marketing/guidelines/#section-badges
Yeah I’ve seen that page; I couldn’t find the logo by itself.
On 19 Dec 2019, at 13.26, Ben Packard notifications@github.com wrote:
Might be able to find one here - https://developer.apple.com/app-store/marketing/guidelines/ https://developer.apple.com/app-store/marketing/guidelines/
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/parse-community/Parse-SDK-iOS-OSX/issues/1440?email_source=notifications&email_token=AAGOPI6RCFWXJDYMDPQH5ILQZNR57A5CNFSM4ITKHKF2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHJOI5Q#issuecomment-567469174, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGOPI7IIIQFVNA5NRX7XATQZNR57ANCNFSM4ITKHKFQ.
@drdaz not sure about that, seems like a good chance it would get rejected by app review? - although I haven't actually seen the guidelines on the button styling
That's the thing I don't like about it. But I've seen it done and get through review, so... 🤷🏽♂️
It just feels wrong.
Well lets see, should be fairly easy to change if problems are encountered, thanks for taking a stab at this!
To be fair, that's the worst that could happen, right? I mean app rejection. 😬
@TomWFox Did you see this btw? https://community.parseplatform.org/t/new-intro-login-flow-for-ios/854
It came to mind again working with ParseUI.
@drdaz I did, it looks pretty good and I think it would be a welcomed addition. However, I'm not sure whether its worth spending too much time on it as I'm not sure how many people actually use ParseUI - although maybe more people would if it was closer to recent design trends etc.
Yeah, agreed. It's hard to know generally how much of the project is in use.
Apple has rejected our new submission due to a lack of Apple Sign In
@UltimatePea As mentioned you must offer sign in with apple if you offer other social sign in options.
Yes, for new apps this is already the policy and for updates it comes into effect in a few months I think.
Note that it is possible to implement Apple Sign In yourself without it being part of the Parse iOS SDK.
I am trying to implement. Able to trigger authorization and receive it. The portion I am not able to figure out is verifying token. Also need to upgrade Parse server to latest.
if I am using email based and Facebook based login then also I need to implement Sign In with Apple?
Yes, if you remove Facebook sign in then you are not required to implement Apple sign in, its up to you.
Okay got it.
@benpackard do you mean that there is a way to sign up / login a PFUser using Apple Signin without it being part of the iOS SDK? Is there documentation on how this can be implemented please?
@chriscborg There's an approach described here that's a great starting point: https://www.back4app.com/docs/platform/sign-in-with-apple
TL;DR the Swift code looks like this:
PFUser.logInWithAuthType(inBackground: "apple", authData: ["token":tokenString, "id": user]).continueWith { task -> Any? in
if ((task.error) != nil){
print("ERROR: \(task.error?.localizedDescription)")
}
return task
if let userObject = task.result {
print("LOGGED IN PARSE")
} else {
// Failed to log in.
print("ERROR LOGGING IN IN PARSE: \(task.error?.localizedDescription)")
}
return nil
}
It still uses the SDK obviously, but it's not like the FB integration where the SDK acts like a facade to the FB login logic. Apple sign in is far simpler to implement.
Thank you @drdaz !
@chriscborg Yep, just make sure you are on the latest version of Parse Server (or at least 3.5ish when support was added). That link from @drdaz was helpful for me too. Here's how I'm getting the auth data from the ASAuthorizationControllerDelegate:
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential, let token = credential.identityToken, let tokenString = String(data: token, encoding: .utf8) else {
// handle this
return
}
let authData = ["token": tokenString, "id": credential.user]
// ... parse log in here
@chriscborg check out this Sample code from Apple. Download the project and explore. https://developer.apple.com/documentation/authenticationservices/adding_the_sign_in_with_apple_flow_to_your_app
It works and I am now trying to figure my business logic to sign up and login to Parse using auth data and verify token process.
I am getting Parse Error 206 when updating logged in user after successful login with auth type. I created another issue but didnt get any response. Can someone check?
https://github.com/parse-community/Parse-SDK-iOS-OSX/issues/1477
This issue has been automatically marked as stale because it has not had recent activity. If you believe it should stay open, please let us know! As always, we encourage contributions, check out the Contributing Guide
Most helpful comment
Hi @ashish-naik, whilst I appreciate this would be a useful feature - our contributors are volunteers and as such cannot implement every feature request & there have been more pressing issues for us to focus on lately.
Perhaps you would be willing to make a PR?