我想生成修改密码的ticket的url,可是一直报400错误

url := "https://test.xx.jp/api/v2/tickets/password-change"

payload := strings.NewReader("{\"user_id\": \"auth0|64265f14712a5faae1efefsfe\"}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "Bearer eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaXNzIjoiaHR0cHM6Ly9hdXRoLWRldi5lbGdhbmEuanAvIn0..3sAOsAQeLiI3M5IK.c-deafda-pG1g0ZkbzX7LFv3ZRM8lI1Es7z_HdfJth-cz-JTRwrz1yBTp7Z7A2enVgpnNh4e3mJ_7YgOyqB9H8EKbWbded54WbEitSaFvcRiPxc3CC3mI0mvmZXtHgaD_bRju_x-8h09DIIX_h0u3hcwOE3DF_9Jb8uq4SrvXsO-Or-IgLt_kga3jeld-UrNb1yYh1rhLySDXOo5KBul-lV5qIb8aMkTXIwCZAFWncw9JgBLEfT_zVFx8gYV7AZ6A9mnmIkyOMxC7b_0mZyqefnMYqnu9M08.puvtlPKmBoBK1V58pnyTVQ")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(string(body))

输出结果为:

{"statusCode":400,"error":"Bad Request","message":"Bad HTTP authentication header format","errorCode":"Bearer"}

如果需要添加其他参数的话,应该加哪个,参数的值又是多少呢? :cold_face:

1 Like

Hi @kixyouken,

Welcome to the Auth0 Community!

The token you have listed here is an encrypted JWT and cannot be used against that endpoint.

To request a token for the management API you must include it’s API identifier with the request. That API identifier should be sent as the audience parameter.

audience=https://TENANT_NAME.auth0.com/api/v2/

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.