Share via


Azure device authentication link with code already embedded

Question

Sunday, July 30, 2017 7:15 AM | 1 vote

When using the Azure device authentication API, the typical workflow is something like this (taken from the Azure CLI):

=> azure loginTo sign in, use a web browser to open the page https://aka.ms/devicelogin and enter 
the code DMYXRD8R3 to authenticate.

The aka.ms URL redirects to: https://login.microsoftonline.com/common/oauth4/deviceauth

Now the user needs to type in the code to proceed.

Question: is there a URL I can use that already embeds the code, so I could provide the user with a clickable URL that doesn't require them to copy+paste the code?

I tried adding the code as a parameter to login.microsoft.online URL using various parameter names such as "code" or "devicecode", but couldn't find any that would do this. In fact, appending "?code=MYCODEHERE" to the URL does make a difference - it changes the behavior completely to provide a JSON object instead of the web page. This is not what I need - I want to get the same web page but as if the user has already typed in the code.

All replies (4)

Monday, July 31, 2017 7:59 AM âś…Answered

Looks like using the same URL, and sending the "code" parameter with POST instead of GET, does the trick.

Need to use Content-Type: application/www-form-urlencoded.


Sunday, July 30, 2017 5:02 PM

For clarification, are you using Azure IoT Hub?

Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.


Monday, July 31, 2017 7:57 AM

nope, it's for software running locally on behalf of the user (running on a server they own)


Monday, July 31, 2017 8:33 AM

Glad to know that your issue has been resolved.

Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.