-
Notifications
You must be signed in to change notification settings - Fork 245
/
azure.identity.aio.AuthorizationCodeCredential.yml
174 lines (150 loc) · 6.62 KB
/
azure.identity.aio.AuthorizationCodeCredential.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
### YamlMime:PythonClass
uid: azure.identity.aio.AuthorizationCodeCredential
name: AuthorizationCodeCredential
fullName: azure.identity.aio.AuthorizationCodeCredential
module: azure.identity.aio
inheritances:
- azure.identity.aio._internal.AsyncContextManager
- azure.identity.aio._internal.get_token_mixin.GetTokenMixin
summary: 'Authenticates by redeeming an authorization code previously obtained from
Microsoft Entra ID.
See [Microsoft Entra ID documentation](https://learn.microsoft.com/entra/identity-platform/v2-oauth2-auth-code-flow)
for more information
about the authentication flow.'
constructor:
syntax: 'AuthorizationCodeCredential(tenant_id: str, client_id: str, authorization_code:
str, redirect_uri: str, *, client_secret: str | None = None, **kwargs: Any)'
parameters:
- name: tenant_id
description: ID of the application's Microsoft Entra tenant. Also called its "directory"
ID.
isRequired: true
types:
- <xref:str>
- name: client_id
description: The application's client ID
isRequired: true
types:
- <xref:str>
- name: authorization_code
description: The authorization code from the user's log-in
isRequired: true
types:
- <xref:str>
- name: redirect_uri
description: The application's redirect URI. Must match the URI used to request
the authorization code.
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: authority
description: 'Authority of a Microsoft Entra endpoint, for example "login.microsoftonline.com",
the authority for Azure Public Cloud (which is the default). <xref:azure.identity.AzureAuthorityHosts>
defines authorities for other clouds.'
types:
- <xref:str>
- name: client_secret
description: One of the application's client secrets. Required only for web apps
and web APIs.
types:
- <xref:str>
- name: additionally_allowed_tenants
description: 'Specifies tenants in addition to the specified "tenant_id"
for which the credential may acquire tokens. Add the wildcard value "*" to allow
the credential to
acquire tokens for any tenant the application can access.'
types:
- <xref:typing.List>[<xref:str>]
examples:
- "Create an AuthorizationCodeCredential.<!--[!code-python[Main](les\\credential_creation_code_snippets.py\
\ )]-->\n\n<!-- literal_block {\"ids\": [], \"classes\": [], \"names\": [], \"dupnames\"\
: [], \"backrefs\": [], \"source\": \"C:\\\\hostedtoolcache\\\\windows\\\\Python\\\
\\3.11.9\\\\x64\\\\Lib\\\\site-packages\\\\py2docfx\\\\dist_temp\\\\46\\\\azure_identity-1.18.0\\\
\\samples\\\\credential_creation_code_snippets.py\", \"xml:space\": \"preserve\"\
, \"force\": false, \"language\": \"python\", \"highlight_args\": {\"linenostart\"\
: 1}, \"linenos\": false} -->\n\n````python\n\n from azure.identity.aio import\
\ AuthorizationCodeCredential\n\n credential = AuthorizationCodeCredential(\n\
\ tenant_id=\"<tenant_id>\",\n client_id=\"<client_id>\",\n authorization_code=\"\
<auth_code>\",\n redirect_uri=\"<redirect_uri>\",\n )\n\n ````\n"
methods:
- uid: azure.identity.aio.AuthorizationCodeCredential.close
name: close
summary: Close the credential's transport session.
signature: async close() -> None
- uid: azure.identity.aio.AuthorizationCodeCredential.get_token
name: get_token
summary: 'Request an access token for *scopes*.
This method is called automatically by Azure SDK clients.
The first time this method is called, the credential will redeem its authorization
code. On subsequent calls
the credential will return a cached access token or redeem a refresh token, if
it acquired a refresh token upon
redeeming the authorization code.'
signature: 'async get_token(*scopes: str, claims: str | None = None, tenant_id:
str | None = None, **kwargs: Any) -> AccessToken'
parameters:
- name: scopes
description: 'desired scopes for the access token. This method requires at least
one scope.
For more information about scopes, see
[https://learn.microsoft.com/entra/identity-platform/scopes-oidc](https://learn.microsoft.com/entra/identity-platform/scopes-oidc).'
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: claims
description: 'additional claims required in the token, such as those returned
in a resource provider''s
claims challenge following an authorization failure.'
types:
- <xref:str>
- name: tenant_id
description: optional tenant to include in the token request.
types:
- <xref:str>
return:
description: An access token with the desired scopes.
types:
- <xref:azure.core.credentials.AccessToken>
exceptions:
- type: azure.core.exceptions.ClientAuthenticationError
description: authentication failed. The error's `message` attribute gives a reason.
Any error response from Microsoft Entra ID is available as the error's `response`
attribute.
- uid: azure.identity.aio.AuthorizationCodeCredential.get_token_info
name: get_token_info
summary: 'Request an access token for *scopes*.
This is an alternative to *get_token* to enable certain scenarios that require
additional properties
on the token. This method is called automatically by Azure SDK clients.
The first time this method is called, the credential will redeem its authorization
code. On subsequent calls
the credential will return a cached access token or redeem a refresh token, if
it acquired a refresh token upon
redeeming the authorization code.'
signature: 'async get_token_info(*scopes: str, options: TokenRequestOptions | None
= None) -> AccessTokenInfo'
parameters:
- name: scopes
description: 'desired scopes for the access token. This method requires at least
one scope.
For more information about scopes, see [https://learn.microsoft.com/entra/identity-platform/scopes-oidc](https://learn.microsoft.com/entra/identity-platform/scopes-oidc).'
isRequired: true
types:
- <xref:str>
keywordOnlyParameters:
- name: options
description: A dictionary of options for the token request. Unknown options will
be ignored. Optional.
types:
- <xref:azure.core.credentials.TokenRequestOptions>
return:
description: An AccessTokenInfo instance containing information about the token.
types:
- <xref:AccessTokenInfo>
exceptions:
- type: azure.core.exceptions.ClientAuthenticationError
description: authentication failed. The error's `message` attribute gives a reason.
Any error response from Microsoft Entra ID is available as the error's `response`
attribute.