7

Is there an API to fetch the device code via Auth0 Java API, we use the following snippet in Go, the question is if there is a standard API or should we make a HTTP request call

url := "https://dev-foo.us.auth0.com/oauth/device/code"

payload := strings.NewReader("client_id=RO6N7mr&scope=openid&audience=https://dev-foo.us.auth0.com/api/v2/")

req, _ := http.NewRequest("POST", url, payload)
3
  • you can check out this blog: auth0.com/developers/hub/code-samples/api/…, has good examples on the same
    – Deb Das
    Apr 18, 2022 at 6:38
  • there is nothing specific to what I am looking for @DebDas
    – Rpj
    Apr 18, 2022 at 8:59
  • Do you mean that you are searching a go package for client oauth2 access?
    – cyberbrain
    Apr 24, 2022 at 11:11

1 Answer 1

2
+50

The documentation tells you that you need to send a POST request like the following:

POST https://YOUR_DOMAIN/oauth/device/code

Content-Type:

application/x-www-form-urlencoded

client_id=YOUR_CLIENT_ID&scope=SCOPE&audience=API_IDENTIFIER

and the response would look like

HTTP/1.1 200 OK
Content-Type: application/json
{
  "device_code":"GmRh...k9eS",
  "user_code":"WDJB-MJHT",
  "verification_uri":"https://YOUR_DOMAIN/device",
  "verification_uri_complete":"https://YOUR_DOMAIN/device?user_code=WDJB-MJHT",
  "expires_in":900, //in seconds
  "interval":5
}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.