Creates a CNAME token to verify the ownership of the domain name.
A CNAME token expires 72 hours after creation. If you create a token while an existing token is still valid, the existing token is returned.
Request syntax
POST /?cname&comp=token HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Content-Type: application/xml
Content-Length: 186
Date: GMT Date
Authorization: SignatureValue
Request headers
RestoreObject uses only common request headers. For more information, see Common request headers.
Request elements
|
Element |
Type |
Required |
Example |
Description |
|
BucketCnameConfiguration |
Container |
Yes |
N/A |
The container that stores the CNAME record. Parent nodes: none Child nodes: Cname |
|
Cname |
Container |
Yes |
N/A |
The container that stores the CNAME information. Parent nodes: BucketCnameConfiguration Child nodes: Domain |
|
Domain |
String |
Yes |
example.com |
The custom domain name. Parent nodes: Cname Child nodes: none |
Response elements
|
Element |
Type |
Example |
Description |
|
CnameToken |
Container |
N/A |
The container that stores the CNAME token information. Parent nodes: none Child nodes: Bucket, Cname, Token, and ExpireTime |
|
Bucket |
String |
examplebucket |
The bucket to which the CNAME record is mapped. Parent nodes: CnameToken Child nodes: none |
|
Cname |
String |
example.com |
The CNAME record mapped to the bucket. Parent nodes: CnameToken Child nodes: none |
|
Token |
String |
be1d49d863dea9ffeff3df7d6455**** |
The CNAME token returned by OSS. Parent nodes: CnameToken Child nodes: none |
|
ExpireTime |
String |
Wed, 23 Feb 2022 21:16:37 GMT |
The time when the CNAME token expires. Parent nodes: CnameToken Child nodes: none |
Examples
-
Sample request
POST /?cname&comp=token HTTP/1.1 Host: oss-example.oss-cn-hangzhou.aliyuncs.com Content-Type: application/xml Content-Length: 186 Date: Thu, 24 Sep 2015 15:39:12 GMT Authorization: OSS qn6q**************:77Dv**************** <BucketCnameConfiguration> <Cname> <Domain>example.com</Domain> </Cname> </BucketCnameConfiguration> -
Sample responses
-
The CNAME token is created.
HTTP/1.1 200 OK x-oss-request-id: 5C1B138A109F4E405B2D Date: Mon, 26 Jul 2021 13:08:38 GMT Content-Length: 118 Content-Type: application/xml Connection: keep-alive Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <CnameToken> <Bucket>examplebucket</Bucket> <Cname>example.com</Cname>; <Token>be1d49d863dea9ffeff3df7d6455****</Token> <ExpireTime>Wed, 23 Feb 2022 21:16:37 GMT</ExpireTime> </CnameToken> -
The number of CNAME tokens exceeds the limit.
HTTP/1.1 400 Bad Request x-oss-request-id: 5C1B138A109F4E405B2D Date: Mon, 26 Jul 2021 13:08:38 GMT Content-Length: 118 Content-Type: application/xml Connection: keep-alive Server: AliyunOSS <?xml version="1.0" encoding="UTF-8"?> <Error> <Code>TooManyCnameToken</Code> <Message>You have attempted to create more cname token than allowed.</Message> <RequestId>6215FD21DA0E27393F004E9E</RequestId> <HostId>127.0.0.1</HostId> <Bucket>examplebucket</Bucket> </Error>
-
OSS SDKs
The following OSS SDKs support the CreateCnameToken operation:
ossutil
For the ossutil command that corresponds to CreateCnameToken, see create-cname-token.
Error codes
|
Error code |
HTTP status code |
Description |
|
TooManyCnameToken |
400 |
The number of CNAME tokens for the bucket exceeds the upper limit of 1000. |
|
NoNeedCreateCnameToken |
403 |
A valid CNAME token already exists for the bucket. You do not need to create a new one. |