Created
February 24, 2023 09:40
-
-
Save Ogaday/c46843b04f5b652c6a62c8039da7ae7d to your computer and use it in GitHub Desktop.
Azure credential helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| """ | |
| from argparse import ArgumentParser | |
| from artifacts_keyring import CredentialProvider # type: ignore | |
| def get_artifact_token(organization: str, feed: str) -> str: | |
| """Get credentials for an azure artifacts feed.""" | |
| provider = CredentialProvider() | |
| _, token = provider.get_credentials( | |
| f"https://pkgs.dev.azure.com/{organization}/_packaging/{feed}/pypi/simple/" | |
| ) | |
| return token | |
| if __name__ == "__main__": | |
| parser = ArgumentParser( | |
| prog="azure_token", | |
| description="Retrieve tokens for Azure Artifact Feeds." | |
| ) | |
| parser.add_argument( | |
| "--organization", | |
| "-o", | |
| help="The organization to which the Artifact Feed belongs.", | |
| required=True, | |
| ) | |
| parser.add_argument( | |
| "--feed", | |
| "-f", | |
| help="The artifact feed for which to retrieve the token.", | |
| required=True, | |
| ) | |
| args = parser.parse_args() | |
| print(get_artifact_credentials(organization=args.organization, feed=args.feed)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment