> ## Documentation Index
> Fetch the complete documentation index at: https://docs.guiji.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Token

> The access token is the service authentication credential for calling DUIX interactive services. All HTTP call interfaces need to place the Token in the Header.

### Method to Get Token

Here's how to get an access token.

### Prerequisites

You have obtained `appKey` and `appId`, which can be found in the created API Keys.
Steps

1. Generate a signature using appKey and appId.
2. Use the signature as the input parameter for the init method of the h5 sdk.

### Signature Generation

The signature uses the JWT mechanism. Users can refer to the following to complete the signature.

### Parameter Description

The following parameters need to be prepared for signature generation

| Name   | Type    | Description                                                    | Example |
| ------ | ------- | -------------------------------------------------------------- | ------- |
| appId  | string  | Session identifier, obtained after successful session creation | xxxxxxx |
| appKey | string  | Session key, obtained after successful session creation        | xxxxxxx |
| sigExp | Integer | Signature validity time, in seconds                            | 1800    |

### Demo Code

The sample code for the signature is as follows, Java version example

```
Import pom dependency

<dependency>
    <groupId>com.auth0</groupId>
    <artifactId>java-jwt</artifactId>
    <version>3.8.3</version>
</dependency>

```

```
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import java.util.Calendar;
import java.util.Date;

public class SigUtils {
    /**
     * Create Signature
     *
     * @param appId  Session Identifier
     * @param appKey Session Key
     * @param sigExp Signature validity time: in seconds
     * @return
     */
    public static String createSig(String appId, String appKey, int sigExp) {
        Calendar nowTime = Calendar.getInstance();
        nowTime.add(Calendar.SECOND, sigExp);
        Date expiresDate = nowTime.getTime();
        return JWT.create()
                //Release date
                .withIssuedAt(new Date())
                //effective time
                .withExpiresAt(expiresDate)
                //load
                .withClaim("appId", appId)
                //encryption
                .sign(Algorithm.HMAC256(appKey));
    }
}

```

\*\* Note: This signature (Token) is the H5 SDK's sign

### Integration Development

With the AppID, secret key, and Token obtained in the above steps, you can learn in detail from the SDK and API overview how to integrate DUIX into your service on various platforms.
