This topic describes how to configure login authentication for your AI assistant. It covers token and OAuth 2.0 authentication for secure and efficient user identity verification and access control.
Prerequisites
You have created an AI assistant. For more information, see Create an AI assistant.
Steps
Anonymous access
This method allows users to access resources without authentication, making it suitable for open, non-sensitive content. You can use the generated URL and script directly, without additional configuration.
Token authentication
Token-based authentication is recommended for the floating widget.
This method authenticates users with a valid token and is ideal for protecting resources and supporting stateless authentication.
-
In the login configuration, select Token authentication.
-
Call the GenerateUserSessionToken API to obtain a
UserSessionTokenfor password-free sign-in. -
Add the
UserSessionTokento the URL.-
For an H5 page, append
?access_session_token=xxxxxxxxxxto the URL. Replacexxxxxxxxxxwith the token from the previous step. -
For a floating widget, add the
access_session_tokenparameter to the script configuration.<script src="https://o.alicdn.com/appflow/chatbot/v1/AppflowChatSDK.js"></script> <script> window.APPFLOW_CHAT_SDK.init({ integrateConfig: { integrateId: 'cit-xxxxxxxxxxxxx', domain: { requestDomain: 'https://example.aa.com (custom domain name)' }, access_session_token: 'xxxxxx (the token from the previous step)' } }); </script>
-
OAuth 2.0 authentication
OAuth 2.0 is a flexible, secure authorization framework that grants third-party applications limited access to specific resources. It is ideal for environments requiring fine-grained permission control and high security.
OAuth 2.0 is suitable for standalone H5 pages and is not applicable to the floating widget.
-
In the login configuration, select OAuth 2.0 authentication.
-
Click the Select Identity drop-down list and select Add New Identity.
-
In the New Identity dialog box, enter an Identity Name and click Next.
For Identity Type, select OAuth 2.0.
-
In the Advanced Settings section, configure the OAuth 2.0 integration information and click Save. The following table describes the key fields.
Parameter
Description
Example
Client ID
The Client ID provided by your OAuth 2.0 system for AppFlow.
12847************
Client Secret
The Client Secret provided by your OAuth 2.0 system for AppFlow.
0889*********************
Authorization URL
Your OAuth 2.0 system's authorization URL.
https://**b.com/lo*/oauth/auth****
Token URL
The URL where AppFlow requests a token from your OAuth 2.0 system.
https://**b.com/lo*/oauth/auth****_token
Response type
When AppFlow requests an authentication URL from your OAuth 2.0 system, the
response_typerequest parameter defaults tocode.code
Scope
The
scopeparameter for the authentication URL request that AppFlow sends to your OAuth 2.0 system is empty by default.repo
Authorization Type
The
grant_typeparameter in the AppFlow request to the token URL of your OAuth 2.0 system defaults toauthorization_code.authorization_code
Userinfo endpoint URL
The URL of your OAuth 2.0 system's userinfo endpoint, from which AppFlow retrieves user information.
https://api.****.com/user
Method to request user info
The method that AppFlow uses to request the user information URL path from your OAuth 2.0 system. The default is GET, and the available options are
GETandPOST.GETJSON Path for user ID
A JSON Path expression for locating user information in the response from the userinfo endpoint.
For example, if the response is
{"userId":"12345667", "info":{"avatar":"https://xxxx.xcom/1xsa.png"},"username":"John Doe"}, you would enter$.userId,$.info.avatar, and$.username.$.id
JSON Path for username
$.login
JSON Path for user avatar
$.avatar_url
-
Select the newly created identity and click Save.