We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I used the demo code to get access token. When I upload a file, it always return "user token expired" message.
Here is the code:
import hashlib import random import time import requests def get_nonce(): pool = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" length = 10 ret = "" while len(ret) < length: ret += random.choice(pool) return ret ts = str(int(time.time())) nonce = get_nonce() access_key = "***" secret_key = "***" concat_string = "uri=/api/v1/openapi/auth&ts=%s&nonce=%s&accessKey=%s&secretKey=%s" % (ts, nonce, access_key, secret_key) sign = hashlib.sha256(concat_string.encode("utf-8")).hexdigest() url = "https://platform.openmmlab.com/gw/user-service/api/v1/openapi/auth" headers = { "ts": ts, "nonce": nonce, "sign": sign, "accessKey": access_key } ret = requests.post(url, headers=headers) print(ret.json()) url = "https://platform.openmmlab.com/gw/upload-service/api/v1/uploadFile" params = { "key": "inference", "tag": "pose" } files = [ ('file', ('', open('/Users/***/Documents/curry_shot.jpg', 'rb'), 'image/jpeg')) ] headers = { "Authorization": ret.json()['data']['accessToken'] } response = requests.request("POST", url, params=params, headers=headers, files=files) print(response.text)
I replace my ak & sk with "***" here for security.
The whole return message is :
{"timestamp":"2025-01-08T02:09:56.576+0000","error":"Internal Server Error","msgCode":"A0202","status":401,"msg":"user token expired"}
I think maybe there is something wrong with the timestamp. But I don't know how to solve the problem. Please help, thanks.
The text was updated successfully, but these errors were encountered:
jbwang1997
No branches or pull requests
I used the demo code to get access token. When I upload a file, it always return "user token expired" message.
Here is the code:
I replace my ak & sk with "***" here for security.
The whole return message is :
I think maybe there is something wrong with the timestamp. But I don't know how to solve the problem.
Please help, thanks.
The text was updated successfully, but these errors were encountered: