UXLINK OAuth 2.0

Overview

Developers can integrate UXLINK Account data into their Dapps by using UXLINK OAuth 2.0. UXLINK OAuth 2.0 allows Dapps to obtain prioritized access to HTTP services. By integrating UXLINK OAuth 2.0, users can securely and conveniently login to Dapps using their UXLINK-connected social accounts or popular digital wallets.

Prerequisite

Before you begin, please ensure you have the following items ready:

β€’ Dapp ID and Dapp Key - apply through πŸ‘‰ UXLINK official account πŸ‘ˆ

β€’ Understanding of the OAuth 2.0 flow

Step 1: Register Your Application

β€’ Provide Application Information

β€’ Project Email: Used to receive development account information and API updates

β€’ Project Name

β€’ Project Domain: The main URL of your application, where users can learn more about your service.

β€’ Logo Image URL: A URL pointing to your logo image, which will be displayed during the authentication process.

β€’ Dapp Redirect URL : Refers to the URL to which the user will be redirected after completing authentication. After receiving this information, we will set up your OAuth configuration and provide you with the Dapp ID and Dapp key. Please keep this information.

Step 2: Use OAuth 2.0 Flow

β€’ The application presents the UXLINK authorization page.

β€’ The user clicks the login button.

β€’ The current web browser is redirected to the authorization page.

β€’ The user is redirected back to the redirect URL controlled by the application, passing the user’s preferred information.

Authorization Request

Build and redirect users to the UXLINK authorization page to initiate the authentication process:

https://openapi.uxlink.io/auth?dappid=DAPPID&replaceUrl=YOUR_REDIRECT_URI&responseType=code&scope=YOUR_SCOPE&state=YOUR_STATE

Param:

  • dappId: The id assigned to your dapp .

  • redirectUrl: After authorization, UXLINK auth2.0 will redirect the URL to the user.

  • responseType: The value is "code".

  • scope: The value is "user.read".

  • state: A unique status value generated by your application to mitigate CSRF attacks.

After successful login and authorization, the user will be redirected to the provided URL, with special code and state value generated by your application.

Get user resource

After users authorize your application, they redirect redirectUrl to your application with parameters. Please exchange the code for an access token. This method must use basic authentication.

curl -X POST 'https://exdapps.uxlink.io/interfa/v2/auth/token' \
-H 'Authorization: <Basic Auth>' \
-H 'Content-Type: application/json' \
-d '{
  "dappid": "DAPPID",
  "code": "CODE",
  "state": "STATE",
  "grantType": "authorization_code",
  "redirectUrl": "https://dapp.uxlink.io/airdrop2049"
}'
// Response Example:
{
  "success": true,
  "msg": "ok",
  "code": 200,
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1...8btpWyFAI_SI",
    "refreshToken": "eyJhbGciOiJIUzI1NiI...8btpWyFAI_SI",
    "expiresIn": 162341315435,
    "uuid": "177123456789"
  }
}

Get user account info

Use the following command to retrieve detailed user information:

curl -X POST 'https://exdapps.uxlink.io/interfa/v2/user/info' \
-H 'Authorization: <AccessToken>' \
-H 'Content-Type: application/json' \
-d '{
  "uuid": "177123456789"
}'
// Response Example:
{
    "success": true,
    "msg": "ok",
    "code": 200,
    "data": {
        "uuid": "177123456789",
        "name": "uxlink",
        "avatar": "https://avatar.jpg", 
        "socialAddress": "0xADDRESS", 
        "chainAddress": "0xADDRESS"
    }
}

Conclusion

This guide Outlines the process of securely integrating UXLINK OAuth 2.0 into your applications to enhance the user authentication experience.

Last updated