:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/../../GodotApplePlugins/doc_classes/ASWebAuthenticationSession.xml. .. _class_ASWebAuthenticationSession: ASWebAuthenticationSession ========================== **Inherits:** :ref:`RefCounted` **<** :ref:`Object` Presents a secure web-based authentication flow (OAuth) using the system browser. .. rst-class:: classref-introduction-group Description ----------- Wraps Apple's ``ASWebAuthenticationSession`` so you can perform OAuth-style logins (e.g. Facebook/Google) with a callback URL. This presents a system-controlled authentication UI and returns the callback URL when the provider redirects back to your app. Notes: - You must configure your callback URL scheme in your app (e.g. via Info.plist URL Types). - Use ``prefers_ephemeral`` if you want to avoid shared cookies (useful for "pick account" flows). .. tabs:: .. code-tab:: gdscript var web_auth := ASWebAuthenticationSession.new() func _ready(): web_auth.completed.connect(_on_web_auth_completed) web_auth.failed.connect(_on_web_auth_failed) web_auth.canceled.connect(_on_web_auth_canceled) func login_facebook(): var auth_url = "https://www.facebook.com/v18.0/dialog/oauth?client_id=...&redirect_uri=mygame://oauth&response_type=code" web_auth.start(auth_url, "mygame", false) func _on_web_auth_completed(callback_url: String): print("Callback URL: ", callback_url) # parse 'code=' etc. func _on_web_auth_failed(message: String): push_error("Web auth failed: %s" % message) func _on_web_auth_canceled(): print("User canceled") .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`cancel`\ (\ ) | +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`start`\ (\ auth_url\: :ref:`String`, callback_scheme\: :ref:`String`, prefers_ephemeral\: :ref:`bool`\ ) | +-------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_ASWebAuthenticationSession_signal_canceled: .. rst-class:: classref-signal **canceled**\ (\ ) :ref:`🔗` Emitted when the user cancels the authentication UI. .. rst-class:: classref-item-separator ---- .. _class_ASWebAuthenticationSession_signal_completed: .. rst-class:: classref-signal **completed**\ (\ callback_url\: :ref:`String`\ ) :ref:`🔗` Emitted when the authentication session completes successfully. \ ``callback_url`` is the full callback URL as a string. .. rst-class:: classref-item-separator ---- .. _class_ASWebAuthenticationSession_signal_failed: .. rst-class:: classref-signal **failed**\ (\ message\: :ref:`String`\ ) :ref:`🔗` Emitted when the authentication session fails. \ ``message`` is the localized error description. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_ASWebAuthenticationSession_method_cancel: .. rst-class:: classref-method |void| **cancel**\ (\ ) :ref:`🔗` Cancels the running authentication session (if any). .. rst-class:: classref-item-separator ---- .. _class_ASWebAuthenticationSession_method_start: .. rst-class:: classref-method :ref:`bool` **start**\ (\ auth_url\: :ref:`String`, callback_scheme\: :ref:`String`, prefers_ephemeral\: :ref:`bool`\ ) :ref:`🔗` Starts the authentication session. \ ``auth_url`` is the provider authorization URL. \ ``callback_scheme`` is your app's callback URL scheme (pass an empty string to not restrict). \ ``prefers_ephemeral`` controls whether the session uses an ephemeral browser session. Returns ``true`` if the session started. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`