我正在尝试使用 Google Cloud Scheduler 向我的应用发送推送:
gcloud beta scheduler jobs create http PUSH --schedule="0 * * * *" --uri="https://fcm.googleapis.com/fcm/send" --description="desc" --headers="Authorization: key=<AUTHKEY> --http-method="POST" --message-body="{\"to\":\"/topics/allDevices\",\"priority\":\"low\",\"data\":{\"success\":\"ok\"}}"
结果始终是 401 Unauthorized。发出命令后:
gcloud beta scheduler jobs describe PUSH
我没有得到这些标题:
description: desc
httpTarget:
body: eyJ0byI6Ii90b3BpY3MvYWxsnByaW9yaXR5IjoRGV2aWNlcyIsIiaGlnaCIsImRhdGEiOnsic3VjY2VzcyI6Im9rIn19 <--- THIS IS WEIRD
headers:
Content-Type: application/octet-stream
User-Agent: Google-Cloud-Scheduler
httpMethod: POST
uri: https://fcm.googleapis.com/fcm/send
lastAttemptTime: '2018-11-07T20:32:37.657408Z'
name: projects/..../locations/europe-west1/jobs/PUSH
retryConfig:
maxBackoffDuration: 3600s
maxDoublings: 16
maxRetryDuration: 0s
minBackoffDuration: 5s
schedule: 0 * * * *
scheduleTime: '2018-11-07T21:00:00.681498Z'
state: ENABLED
status:
code: 16
timeZone: Etc/UTC
userUpdateTime: '2018-11-07T20:29:15Z'