Loading...
Loading...
Use when you need to implement CloudBase Auth v2 over raw HTTP endpoints (login/signup, tokens, user operations) from backends or scripts that are not using the Web or Node SDKs.
npx skill4agent add tencentcloudbase/awesome-cloudbase-examples auth-http-api-cloudbase@cloudbase/js-sdk@2.x@cloudbase/node-sdkenvclientIdclientSecret/source-of-truth/auth/http-api/登录认证接口.info.mdx*.api.mdxhttps://${env}.ap-shanghai.tcb-api.tencentcloudapi.com/auth/v1/...x-device-idx-request-idAuthorizationBearer <access_token>-u clientId:clientSecretenv="your-env-id"
deviceID="backend-service-1"
requestID="$(uuidgen || echo manual-request-id)"
clientId="your-client-id"
clientSecret="your-client-secret"
base="https://${env}.ap-shanghai.tcb-api.tencentcloudapi.com/auth/v1"access_tokenrefresh_tokenAuthorization: Bearer ${accessToken}verificationcurl "${base}/signin" \
-X POST \
-H "x-device-id: ${deviceID}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{"username":"test@example.com","password":"your password"}'access_tokenrefresh_tokencurl "${base}/verification" \
-X POST \
-H "x-device-id: ${deviceID}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{"phone_number":"+86 13800000000"}'curl "${base}/verification/verify" \
-X POST \
-H "x-device-id: ${deviceID}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{"verification_code":"000000","verification_id":"<from previous step>"}'curl "${base}/signup" \
-X POST \
-H "x-device-id: ${deviceID}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{
"phone_number":"+86 13800000000",
"verification_code":"000000",
"verification_token":"<from verify>",
"name":"手机用户",
"password":"password",
"username":"username"
}'curl "${base}/signin-anonymously" \
-X POST \
-H "x-device-id: ${deviceID}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{}'curl "${base}/token" \
-X POST \
-H "x-device-id: ${deviceID}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{"grant_type":"refresh_token","refresh_token":"<refresh_token>"}'curl "${base}/token/introspect?token=${accessToken}" \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}"curl "${base}/revoke" \
-X POST \
-H "x-request-id: ${requestID}" \
-u "${clientId}:${clientSecret}" \
--data-raw '{"token":"${accessToken}"}'# Get current user
curl "${base}/user/me" \
-H "Authorization: Bearer ${accessToken}"
# Change password
curl "${base}/user/password" \
-X PATCH \
-H "Authorization: Bearer ${accessToken}" \
--data-raw '{"old_password":"old","new_password":"new"}'DELETE ${base}/user/me${base}/user/providers