doc-exports/docs/ocr/api-ref/ocr_03_0005.html
Sheng, Lichang f0fbeaa320 OCR api 20240111 v2
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Sheng, Lichang <lichangsheng1@noreply.gitea.eco.tsi-dev.otc-service.com>
Co-committed-by: Sheng, Lichang <lichangsheng1@noreply.gitea.eco.tsi-dev.otc-service.com>
2024-01-17 10:01:47 +00:00

2.4 KiB

Authentication

Token-based Authentication

A token is valid for 24 hours. When using a token for authentication, cache it to prevent frequently calling the IAM API.

A token is used to acquire temporary permissions. During API authentication using a token, the token is added to a request to get permissions for calling the API.

To call an API to obtain a user token, you need to set auth.scope to project in the request body.

{ 
    "auth": { 
        "identity": { 
            "methods": [ 
                "password" 
            ], 
            "password": { 
                "user": { 
                    "name": "user_name", 
                    "password": "********", 
                    "domain": { 
                        "name": "domain_name" 
                    } 
                } 
            } 
        }, 
        "scope": { 
            "project": { 
                "name": "xxxxxxxx" 
            } 
        } 
    } 
}

After a token is obtained, the X-Auth-Token header must be added to requests to specify the token when calling other APIs. For example, if the token is ABCDEFJ...., add X-Auth-Token: ABCDEFJ.... to a request as follows:

Content-Type: application/json 
X-Auth-Token: ABCDEFJ....