0

I am trying to implement OAuth 2.0 Device Authentication Flow. In first step i received device code successfully. Then i have created JWT token using device code and and other details. Send it to oAuth endpoint as per documentation in my polling request. In response i receive following error.

{
    "error": "invalid_request",
    "error_description": "invalid device code"
}

Here are different format of my polling request that i have tried:

{
  "grant_type": "device",
  "client_id": "3MVG9ZL0ppGP5UrAeSesYYnKvM92KLFkRmZwR8mEz_DvAQiN1LLMRClcAcDlsKy44qjwvWCvBWwFvFhVrs5A1",
  "client_secret" : "XXXXXXXXXXXXXX",
  "code": "M01WRzlaTDBwcEdQNVVyQWVTZXNZWW5Ldk05MktMRmtSbVp3UjhtRXpfRHZBUWlOMUxMTVJDbGNBY0Rsc0t5NDRxand2V0N2Qld3RnZGaFZyczVBMTsxMTQuMTQzLjUwLjk1OzE1MzY0NjkyNTQxNjU7N1ZZN1I3N1U"
}

Try 2:

{
  "grant_type": "device",
  "client_id": "3MVG9ZL0ppGP5UrAeSesYYnKvM92KLFkRmZwR8mEz_DvAQiN1LLMRClcAcDlsKy44qjwvWCvBWwFvFhVrs5A1",
  "code": "M01WRzlaTDBwcEdQNVVyQWVTZXNZWW5Ldk05MktMRmtSbVp3UjhtRXpfRHZBUWlOMUxMTVJDbGNBY0Rsc0t5NDRxand2V0N2Qld3RnZGaFZyczVBMTsxMTQuMTQzLjUwLjk1OzE1MzY0NjkyNTQxNjU7N1ZZN1I3N1U"
}

Try 3:

{
  "grant_type": "device",
  "client_id": "3MVG9ZL0ppGP5UrAeSesYYnKvM92KLFkRmZwR8mEz_DvAQiN1LLMRClcAcDlsKy44qjwvWCvBWwFvFhVrs5A1",
  "device_code": "M01WRzlaTDBwcEdQNVVyQWVTZXNZWW5Ldk05MktMRmtSbVp3UjhtRXpfRHZBUWlOMUxMTVJDbGNBY0Rsc0t5NDRxand2V0N2Qld3RnZGaFZyczVBMTsxMTQuMTQzLjUwLjk1OzE1MzY0NjkyNTQxNjU7N1ZZN1I3N1U"
}

Try 4

{
  "grant_type": "device",
  "client_id": "3MVG9ZL0ppGP5UrAeSesYYnKvM92KLFkRmZwR8mEz_DvAQiN1LLMRClcAcDlsKy44qjwvWCvBWwFvFhVrs5A1",
  "devicecode": "M01WRzlaTDBwcEdQNVVyQWVTZXNZWW5Ldk05MktMRmtSbVp3UjhtRXpfRHZBUWlOMUxMTVJDbGNBY0Rsc0t5NDRxand2V0N2Qld3RnZGaFZyczVBMTsxMTQuMTQzLjUwLjk1OzE1MzY0NjkyNTQxNjU7N1ZZN1I3N1U"
}

Here is screen shot from postman Received device code and other details Got error in step 2

Can anyone please suggest what is correct format of the the request?

Ref: https://help.salesforce.com/articleView?id=remoteaccess_oauth_device_flow.htm&type=5

https://jwt.io/

2

To get the access token , in the second request you need to pass the following

POST /services/oauth2/token HTTP/1.1

grant_type=device&client_id="your client id"&code="device code returned in Step 1"

  • Thank you! .. I dont know why doc shows the sample as JWT token. – AtulRajguru9 Sep 9 '18 at 7:23

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.