You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#! /usr/bin/env python
# coding=utf-8
import json
from aliyunsdkcore . client import AcsClient
from aliyunsdkcore . request import CommonRequest
from Config import *
def getToken ( ) :
# 创建AcsClient实例
client = AcsClient (
' LTAI5t5jxkgJtRK8wew8fnbq ' , ' b8HXNGz7IkI3Dhv7BZx9BNBEZy1uku ' ,
" cn-shanghai "
)
# 创建request, 并设置参数。
request = CommonRequest ( )
request . set_method ( ' POST ' )
request . set_domain ( ' nls-meta.cn-shanghai.aliyuncs.com ' )
request . set_version ( ' 2019-02-28 ' )
request . set_action_name ( ' CreateToken ' )
try :
response = client . do_action_with_exception ( request )
#print(response)
jss = json . loads ( response )
if ' Token ' in jss and ' Id ' in jss [ ' Token ' ] :
token = jss [ ' Token ' ] [ ' Id ' ]
#expireTime = jss['Token']['ExpireTime']
#print("token = " + token)
return token
#print("expireTime = " + str(expireTime))
except Exception as e :
print ( e )
if __name__ == ' __main__ ' :
print ( getToken ( ) )