3

After checking the official document, the device_token can not be used for hms_server to send downlink message. If i want to access hms_server, i must request another oauth2 token. Is it mean both the device_token and hms_server_token should be updated all the time, or choice only one like device_token to send downlink message?

URL: https://push-api.cloud.huawei.com/v1/appid/messages:send

Request Header: 
Authorization Bear token (need to request from hms_server, the device_token is only used for identify the address of device)
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
ccd
  • 5,788
  • 10
  • 46
  • 96
  • Does this answer your question? [How to get access token for Huawei Api for sending push to device?](https://stackoverflow.com/questions/65359394/how-to-get-access-token-for-huawei-api-for-sending-push-to-device) – mohax Sep 06 '21 at 06:59
  • And this is how to send message to device, using token from previous comment: https://stackoverflow.com/questions/65359941/how-to-send-push-to-huawei-device-using-huawei-push-kit-api – mohax Sep 06 '21 at 07:00
  • Why not use the device_token to replace the server_oauth_token? – ccd Sep 06 '21 at 07:09

1 Answers1

1

Both device_token and access_token are required. The device_token is obtained by the client and updated when the token changes. Changed scenario pls refer to this Docs.

The access_token has a validity period. When the access_token is obtained, the validity period is returned. Generally, the validity period is one hour. The access_token is used within the validity period and does not need to be updated each time.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • If the access_token is outdated, can i use the previous token automatically to generate the new token and send the push message? – ccd Sep 06 '21 at 07:17
  • No you can't. If the `access_token` is outdated, you need to use the API to obtain it again. – zhangxaochen Sep 06 '21 at 07:32