Updated on 2025-05-13 GMT+08:00

Sharing Token

You can call this API (described in Obtaining a Sharing Token) to obtain a temporary token. You can use this temporary token to access the file without using the access-token for authentication.

To share a token, perform the following steps:

  1. Obtaining a Sharing Token: obtains a temporary token.
  2. Viewing a Shared Object File: Use a temporary token to access the file.

Obtaining a Sharing Token

  • Function

    Used to obtain a temporary token. You can use this token to access files without using the access-token for authentication. The obtained token is temporary and has a validity period.

  • URI

    POST Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/connectors/{connector_type}/{connector_name}/sharetoken

    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    connector_type

    Yes

    String

    Explanation

    Type of a connector.

    Constraints

    None

    Value

    • obs: connector for interconnecting with OBS.
    • minio: connector for connecting to MINIO.
    • objectstorageproxy: object storage proxy type.

    Default value

    None

    connector_name

    Yes

    String

    Explanation

    Name of the connector instance, that is, the connector instance name set when the connector is created.

    Constraints

    None

    Value

    None

    Default value

    None

  • Request Parameters
    Table 2 Request body parameters

    Parameter

    Mandatory

    Type

    Description

    shareType

    Yes

    Integer

    Explanation

    Sharing type.

    Constraints

    None

    Value

    • 0: sharing by file.
    • 1: sharing by directory.
    • 2: Use character arrays to indicate multiple file paths.

    Default value

    None

    key

    No

    String

    Explanation

    Shared objects and directories.

    Constraints

    If the value is a directory, it must end with /.

    Value

    None

    Default value

    None

    keys

    No

    String

    Explanation

    Multiple file paths.

    Constraints

    None

    Value

    None

    Default value

    None

    timeoutInMinutes

    Yes

    Integer

    Explanation

    Validity period of the sharing, in minutes.

    Constraints

    None

    Value

    1 to 1440, that is, 1 to 1440 minutes.

    Default value

    None

  • Response Parameters
    Table 3 Response parameters

    Parameter

    Type

    Description

    resCode

    String

    Explanation

    Return code.

    Value

    If the request is successful, 0 is returned. For details about other error codes, see Error Codes.

    resMsg

    String

    Explanation

    Message returned.

    Value

    If the request is successful, "Success" is returned. In other cases, an error message is returned.

    result

    Object

    Explanation

    Returned result object. If the object contains the shareToken field, the token is a temporary token.

  • Example Request

    An OBS connector has been created. The connector instance name is Namespace __TestOBS. Call the following request to obtain a temporary access token for some files:

    POST https://Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/connectors/obs/Namespace __TestOBS/sharetoken
    
    {
     "shareType": 0,
     "key": "a/b/c/1.txt",
     "keys": [
      "a/b/c/2.txt",
      "ROMAExchange.zip",
      "some/dir/c.jpg"
     ],
     "timeoutInMinutes": 60
    }

    Users can access the file after obtaining the URL. Therefore, do not share sensitive files.

  • Example Response
    {
     "resCode": "0",
    	"resMsg": "Success",
     "result": {
      "shareToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJz***tOejj6NEo"
     }
    }

    Record the value of shareToken for subsequent file access.

Viewing a Shared Object File

  • Function

    See Obtaining a Sharing Token to view the file based on the returned temporary token.

  • URI

    GET Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/objectstorage/viewshareobject?object=X&shareToken=Y

    Table 4 URI parameters

    Parameter

    Mandatory

    Type

    Description

    object

    Yes

    String

    Explanation

    Full path of the file in the bucket, including the file name.

    Constraints

    None

    Value

    None

    Default value

    None

    shareToken

    Yes

    String

    Explanation

    Temporary token returned in Obtaining a Sharing Token.

    Constraints

    None

    Value

    None

    Default value

    None

  • Request Parameters

    None

  • Response Parameters

    Only the file content is returned.

  • Example Request

    An OBS connector has been created. The connector instance name is Namespace __TestOBS. Call the following request to use the temporary access token to view the a/b/c/1.txt file in the bucket.

    GET https://Huawei Cloud Astro Zero domain name/u-route/baas/sys/v1.1/objectstorage/viewshareobject?object=a/b/c/1.txt&shareToken=eyJhbGciOiJIUzI1NiIsInR******W8FYgXTGTAtOejj6NEo
  • Example Response
    test