:github_url: hide
:allow_comments: False
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from AuthenticationServices/AuthenticationServicesGuide.md.
.. _authenticationservices_authenticationservicesguide__using-apple-s-authenticationservices-apis-with-godot:
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).
.. _authenticationservices_authenticationservicesguide__entitlements:
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).
.. _authenticationservices_authenticationservicesguide__ios:
iOS
---
Set at Project -> Export -> iOS -> ``entitlements/additional``:
.. code-block:: xml
com.apple.developer.applesignin
Default
.. _authenticationservices_authenticationservicesguide__macos:
macOS
-----
Set the same entitlements as above (eg. when running codesign):
.. code-block:: sh
codesign --force --options=runtime --verbose --timestamp \
--entitlements entitlements.plist --sign "" \
"MyApp.app/Contents/MacOS/MyApp"
where ``entitlements.plist`` contains again:
.. code-block:: xml
com.apple.developer.applesignin
Default
.. _authenticationservices_authenticationservicesguide__quick-start:
Quick Start
===========
For very simple uses, you can use:
.. code-block:: gdscript
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.