@@ -25,29 +25,36 @@ type EnvironmentCredentialOptions struct {
2525// EnvironmentCredential authenticates a service principal with a secret or certificate, or a user with a password, depending
2626// on environment variable configuration. It reads configuration from these variables, in the following order:
2727//
28- // Service principal:
29- // - AZURE_TENANT_ID: ID of the service principal's tenant. Also called its "directory" ID.
30- // - AZURE_CLIENT_ID: the service principal's client ID
31- // - AZURE_CLIENT_SECRET: one of the service principal's client secrets
28+ // Service principal with client secret
3229//
33- // Service principal with certificate:
34- // - AZURE_TENANT_ID: ID of the service principal's tenant. Also called its "directory" ID.
35- // - AZURE_CLIENT_ID: the service principal's client ID
36- // - AZURE_CLIENT_CERTIFICATE_PATH: path to a PEM or PKCS12 certificate file including the private key. The
37- // certificate must not be password-protected.
30+ // AZURE_TENANT_ID: ID of the service principal's tenant. Also called its "directory" ID.
3831//
39- // User with username and password:
40- // - AZURE_CLIENT_ID: the application's client ID
41- // - AZURE_USERNAME: a username (usually an email address)
42- // - AZURE_PASSWORD: that user's password
43- // - AZURE_TENANT_ID: (optional) tenant to authenticate in. If not set, defaults to the "organizations" tenant, which
44- // can authenticate only Azure Active Directory work or school accounts.
32+ // AZURE_CLIENT_ID: the service principal's client ID
33+ //
34+ // AZURE_CLIENT_SECRET: one of the service principal's client secrets
35+ //
36+ // Service principal with certificate
37+ //
38+ // AZURE_TENANT_ID: ID of the service principal's tenant. Also called its "directory" ID.
39+ //
40+ // AZURE_CLIENT_ID: the service principal's client ID
41+ //
42+ // AZURE_CLIENT_CERTIFICATE_PATH: path to a PEM or PKCS12 certificate file including the unencrypted private key.
43+ //
44+ // User with username and password
45+ //
46+ // AZURE_TENANT_ID: (optional) tenant to authenticate in. Defaults to "organizations".
47+ //
48+ // AZURE_CLIENT_ID: client ID of the application the user will authenticate to
49+ //
50+ // AZURE_USERNAME: a username (usually an email address)
51+ //
52+ // AZURE_PASSWORD: the user's password
4553type EnvironmentCredential struct {
4654 cred azcore.TokenCredential
4755}
4856
49- // NewEnvironmentCredential creates an EnvironmentCredential.
50- // options: Optional configuration. Pass nil to accept default settings.
57+ // NewEnvironmentCredential creates an EnvironmentCredential. Pass nil to accept default options.
5158func NewEnvironmentCredential (options * EnvironmentCredentialOptions ) (* EnvironmentCredential , error ) {
5259 if options == nil {
5360 options = & EnvironmentCredentialOptions {}
@@ -104,9 +111,7 @@ func NewEnvironmentCredential(options *EnvironmentCredentialOptions) (*Environme
104111 return nil , errors .New ("incomplete environment variable configuration. Only AZURE_TENANT_ID and AZURE_CLIENT_ID are set" )
105112}
106113
107- // GetToken obtains a token from Azure Active Directory. This method is called automatically by Azure SDK clients.
108- // ctx: Context used to control the request lifetime.
109- // opts: Options for the token request, in particular the desired scope of the access token.
114+ // GetToken requests an access token from Azure Active Directory. This method is called automatically by Azure SDK clients.
110115func (c * EnvironmentCredential ) GetToken (ctx context.Context , opts policy.TokenRequestOptions ) (* azcore.AccessToken , error ) {
111116 return c .cred .GetToken (ctx , opts )
112117}
0 commit comments