Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Demo] Allow specifying a custom access token #12

Closed
wants to merge 2 commits into from
Closed

Conversation

jiasli
Copy link
Owner

@jiasli jiasli commented Aug 26, 2020

Description

Allow specifying a custom access token by monkey-patching azure.cli.core._profile.Profile.get_login_credentials.

Testing Guide

# With --access-token
> az group show -n fy --subscription 0b1f6471-1bf0-4dda-aec3-cb9272f09590 --access-token "eyJ0eXAiO..."
Subscription '0b1f6471-1bf0-4dda-aec3-cb9272f09590' not recognized.
Using the provided access token.
{
  "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/fy",
  "location": "westus",
  "managedBy": null,
  "name": "fy",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null,
  "type": "Microsoft.Resources/resourceGroups"
}

# Without --access-token
> az group show -n fy
Using the credential from `az login`.
{
  "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/fy",
  "location": "westus",
  "managedBy": null,
  "name": "fy",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null,
  "type": "Microsoft.Resources/resourceGroups"
}

Note that this warning

Subscription '0b1f6471-1bf0-4dda-aec3-cb9272f09590' not recognized.

can't be disabled by monkey-patching because it is printed before the command reaches get_resource_group. To hide it, use --only-show-errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant