Using Apple’s AuthenticationServices APIs with Godot

This is a guide on using Sign in with Apple via the AuthenticationServices APIs in this Godot addon. For an overview of what you can do with AuthenticationServices, check [Apple’s AuthenticationServices Documentation](https://developer.apple.com/documentation/authenticationservices/).

As with the rest of GodotApplePlugins, the binding surfaces the same class names that Apple uses (prefixed with AS) to simplify looking things up and finding resources online. Method names follow the Godot naming scheme (snake_case instead of camelCase).

Entitlements

Make sure that your iOS or Mac app have the com.apple.developer.applesignin entitlement. When debugging on macOS, you need to resign the official Godot download with this entitlement (you must download a provisioning profile that contains the entitlement, or the APIs will fail).

iOS

Set at Project -> Export -> iOS -> entitlements/additional:

<key>com.apple.developer.applesignin</key>
<array>
    <string>Default</string>
</array>

macOS

Set the same entitlements as above (eg. when running codesign):

codesign --force --options=runtime --verbose --timestamp \
  --entitlements entitlements.plist --sign "<SIGN_ENTITY>" \
  "MyApp.app/Contents/MacOS/MyApp"

where entitlements.plist contains again:

<key>com.apple.developer.applesignin</key>
<array>
    <string>Default</string>
</array>

Quick Start

For very simple uses, you can use:

var auth_controller = ASAuthorizationController.new()

func _ready():
    auth_controller.authorization_completed.connect(_on_authorization_completed)
    auth_controller.authorization_failed.connect(_on_authorization_failed)

func _on_sign_in_button_pressed():
    # Request full name and email
    auth_controller.signin_with_scopes(["full_name", "email"])

func _on_authorization_completed(credential):
    if credential is ASAuthorizationAppleIDCredential:
        print("User ID: ", credential.user)
        print("Email: ", credential.email)
        print("Full Name: ", credential.fullName)
    elif credential is ASPasswordCredential:
        print("User: ", credential.user)
        print("Password: ", credential.password)

For more advanced users, you will find that the API replicates Apple’s API, and it surfaces the various features that you expect from it.