ASAuthorizationController

Inherits: RefCounted < Object

Manages authorization requests for Apple ID and other services.

Description

This class handles the presentation and management of authorization flows, such as Sign in with Apple. It interacts with the ASAuthorizationAppleIDCredential and ASPasswordCredential classes to return the result of an authorization request.

You can use signin_with_scopes() to request specific scopes (e.g., full name and email) or signin() for a default sign-in flow.

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)

func _on_authorization_failed(error_message):
    print("Authorization failed: ", error_message)

Methods

void

signin()

void

signin_with_scopes(scopeStrings: Array)


Signals

authorization_completed(credential: RefCounted) 🔗

Emitted when the authorization request completes successfully.

credential is usually an ASAuthorizationAppleIDCredential or ASPasswordCredential. It can be null if the credential type is unsupported.


authorization_failed(error: String) 🔗

Emitted when the authorization request fails.

error contains the localized description of the error.


Method Descriptions

void signin() 🔗

Call this method to initiate the signin with Apple workflow with the default scopes (email, full_name),

this will raise the signal authorization_completed upon success, or the authorization_failed on failure.


void signin_with_scopes(scopeStrings: Array) 🔗

Call this method to initiate the signin with Apple workflow with a specific set of scopes, currently they can be any of email

and full_name. This will raise the event authorization_completed upon

success, or the authorization_failed on failure.