Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.8 KB

README.rst

File metadata and controls

55 lines (41 loc) · 1.8 KB

azlogin

Azure Login OAuth 2.0 Device Flow Console Program.

Usage

Run and get bearer token for each subscription

$ .\azlogin
To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code G9HFZ4NCY to authenticate.
....
[
   {
     "tenantId": "xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx",
     "subscriptionId": "xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx",
     "subscriptionName": "Developer Program Benefit",
     "bearer": "********************************************a"
   },
   {
     "tenantId": "xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx",
     "subscriptionId": "xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx",
     "subscriptionName": "foo",
     "bearer": "********************************************a"
   },
   {
     "tenantId": "xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx",
     "subscriptionId": "xxxxxxxx-xxxx-xxxxxxxxx-xxxxxxxxxxxx",
     "subscriptionName": "kinmugi",
     "bearer": "********************************************a"
   }
]

Run and get bearer token for each subscription. Save the bearer token after logging in the variable and execute the API. For cutting bearer token, use jp (JMESPath).

$ cat filter.jp
[?subscriptionName == 'kinmugi'].bearer|[0]

$ $bearer = (.\azlogin | jp -u -e filter.jp)

$ curl "https://management.azure.com/subscriptions/xxxxxxxx-.../resourcegroups?api-version=2017-05-10" -H  "Authorization: Bearer $bearer"

See