Quick Start
-
Add an
OAuth2node to your main scene or to an autoload/global scene. -
Set the Browser Mode in the inspector:
EXTERNAL(default, system browser) orIN_APP(Chrome Custom Tab on Android / ASWebAuthenticationSession on iOS). -
Add a
Deeplinknode to your scene and configure your redirect URI.Note: A
Deeplinknode is required in all cases except iOS withIN_APPmode, where the OS intercepts the redirect internally. -
Assign the
Deeplinknode path in theOAuth2node inspector. -
Configure provider settings (preset or custom).
-
Connect to
OAuth2signals. -
Call
authorize()to start authentication. Callcancel_auth()to cancel an in-progress in-app session (safe no-op inEXTERNALmode). -
Use the
OAuth2node’s public methods to initiate authorization and manage sessions. -
Listen to signals to handle success, errors, and cancellations.
Example:
@onready var oauth2 := $OAuth2
func _ready():
oauth2.auth_started.connect(_on_auth_started)
oauth2.auth_success.connect(_on_auth_success)
oauth2.auth_error.connect(_on_auth_error)
oauth2.auth_cancelled.connect(_on_auth_cancelled)
func login():
oauth2.authorize()
func cancel_login():
oauth2.cancel_auth() # safe to call in EXTERNAL mode (no-op)
func _on_auth_started():
print("Authentication started")
func _on_auth_success(token_data: Dictionary):
print("Authentication success:", token_data)
func _on_auth_error(msg: String):
print("Authentication error:", msg)
func _on_auth_cancelled():
print("Authentication cancelled")