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

[azidentity] Update code to use the latest azcore #15137

Merged
merged 4 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions sdk/azidentity/aad_identity_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (c *aadIdentityClient) createRefreshTokenRequest(ctx context.Context, tenan
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return req, nil
Expand All @@ -216,7 +216,7 @@ func (c *aadIdentityClient) createClientSecretAuthRequest(ctx context.Context, t
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}

Expand All @@ -242,7 +242,7 @@ func (c *aadIdentityClient) createClientCertificateAuthRequest(ctx context.Conte
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return req, nil
Expand Down Expand Up @@ -288,7 +288,7 @@ func (c *aadIdentityClient) createUsernamePasswordAuthRequest(ctx context.Contex
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return req, nil
Expand Down Expand Up @@ -339,7 +339,7 @@ func (c *aadIdentityClient) createDeviceCodeAuthRequest(ctx context.Context, ten
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return req, nil
Expand Down Expand Up @@ -373,7 +373,7 @@ func (c *aadIdentityClient) createDeviceCodeNumberRequest(ctx context.Context, t
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return req, nil
Expand Down Expand Up @@ -436,7 +436,7 @@ func (c *aadIdentityClient) createAuthorizationCodeAuthRequest(ctx context.Conte
if err != nil {
return nil, err
}
if err := req.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := req.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return req, nil
Expand Down
4 changes: 2 additions & 2 deletions sdk/azidentity/aad_identity_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestTelemetryDefaultUserAgent(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.Fatalf("unexpected status code: %d", resp.StatusCode)
}
if ua := resp.Request.Header.Get(azcore.HeaderUserAgent); !strings.HasPrefix(ua, UserAgent) {
if ua := resp.Request.Header.Get(headerUserAgent); !strings.HasPrefix(ua, UserAgent) {
t.Fatalf("unexpected User-Agent %s", ua)
}
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestTelemetryCustom(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.Fatalf("unexpected status code: %d", resp.StatusCode)
}
if ua := resp.Request.Header.Get(azcore.HeaderUserAgent); !strings.HasPrefix(ua, customTelemetry+" "+UserAgent) {
if ua := resp.Request.Header.Get(headerUserAgent); !strings.HasPrefix(ua, customTelemetry+" "+UserAgent) {
t.Fatalf("unexpected User-Agent %s", ua)
}
}
4 changes: 2 additions & 2 deletions sdk/azidentity/authorization_code_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func (c *AuthorizationCodeCredential) GetToken(ctx context.Context, opts azcore.
return tk, nil
}

// AuthenticationPolicy implements the azcore.Credential interface on AuthorizationCodeCredential.
func (c *AuthorizationCodeCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on AuthorizationCodeCredential.
func (c *AuthorizationCodeCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/azidentity/authorization_code_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAuthorizationCodeCredential_CreateAuthRequestSuccess(t *testing.T) {
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatal("Unexpected value for Content-Type header")
}
body, err := ioutil.ReadAll(req.Request.Body)
Expand Down
9 changes: 9 additions & 0 deletions sdk/azidentity/azidentity.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ const (
defaultSuffix = "/.default"
)

const (
headerXmsDate = "x-ms-date"
headerUserAgent = "User-Agent"
headerURLEncoded = "application/x-www-form-urlencoded"
headerAuthorization = "Authorization"
headerMetadata = "Metadata"
headerContentType = "Content-Type"
)

Comment on lines +31 to +39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a benefit to put these in internal? Will other packages also use these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same as you, but look at the thread in this PR: #15038. There's a point that it might take too long to make changes to azcore if we need to add new headers and then release a new version of the internal module.

Still I think there's an argument to be made for having some of the more common ones in the internal module if it makes it easier to handle for other SDK devs.

const tenantIDValidationErr = "Invalid tenantID provided. You can locate your tenantID by following the instructions listed here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names."

var (
Expand Down
6 changes: 4 additions & 2 deletions sdk/azidentity/azure_cli_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (c *AzureCLICredential) GetToken(ctx context.Context, opts azcore.TokenRequ
return at, nil
}

// AuthenticationPolicy implements the azcore.Credential interface on AzureCLICredential.
func (c *AzureCLICredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on AzureCLICredential.
func (c *AzureCLICredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

Expand Down Expand Up @@ -188,3 +188,5 @@ func parseExpirationDate(input string) (*time.Time, error) {
}
return &expirationDate, nil
}

var _ azcore.TokenCredential = (*AzureCLICredential)(nil)
8 changes: 4 additions & 4 deletions sdk/azidentity/bearer_token_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ type bearerTokenPolicy struct {
options azcore.TokenRequestOptions
}

func newBearerTokenPolicy(creds azcore.TokenCredential, opts azcore.AuthenticationPolicyOptions) *bearerTokenPolicy {
func newBearerTokenPolicy(creds azcore.TokenCredential, opts azcore.AuthenticationOptions) *bearerTokenPolicy {
return &bearerTokenPolicy{
cond: sync.NewCond(&sync.Mutex{}),
creds: creds,
options: opts.Options,
options: opts.TokenRequest,
}
}

Expand Down Expand Up @@ -100,8 +100,8 @@ func (b *bearerTokenPolicy) Do(req *azcore.Request) (*azcore.Response, error) {
b.expiresOn = tk.ExpiresOn
b.unlock()
}
req.Request.Header.Set(azcore.HeaderXmsDate, time.Now().UTC().Format(http.TimeFormat))
req.Request.Header.Set(azcore.HeaderAuthorization, header)
req.Request.Header.Set(headerXmsDate, time.Now().UTC().Format(http.TimeFormat))
req.Request.Header.Set(headerAuthorization, header)
return req.Next()
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/azidentity/bearer_token_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func defaultTestPipeline(srv azcore.Transport, cred azcore.Credential, scope str
return azcore.NewPipeline(
srv,
azcore.NewRetryPolicy(&retryOpts),
cred.AuthenticationPolicy(azcore.AuthenticationPolicyOptions{Options: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
cred.NewAuthenticationPolicy(azcore.AuthenticationOptions{TokenRequest: azcore.TokenRequestOptions{Scopes: []string{scope}}}),
azcore.NewLogPolicy(nil))
}

Expand All @@ -55,7 +55,7 @@ func TestBearerPolicy_SuccessGetToken(t *testing.T) {
t.Fatalf("Expected nil error but received one")
}
const expectedToken = bearerTokenPrefix + tokenValue
if token := resp.Request.Header.Get(azcore.HeaderAuthorization); token != expectedToken {
if token := resp.Request.Header.Get(headerAuthorization); token != expectedToken {
t.Fatalf("expected token '%s', got '%s'", expectedToken, token)
}
}
Expand Down
6 changes: 4 additions & 2 deletions sdk/azidentity/chained_token_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func (c *ChainedTokenCredential) GetToken(ctx context.Context, opts azcore.Token
return nil, credErr
}

// AuthenticationPolicy implements the azcore.Credential interface on ChainedTokenCredential and sets the bearer token
func (c *ChainedTokenCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on ChainedTokenCredential and sets the bearer token
func (c *ChainedTokenCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

Expand All @@ -82,3 +82,5 @@ func createChainedErrorMessage(errList []*CredentialUnavailableError) string {

return msg
}

var _ azcore.TokenCredential = (*ChainedTokenCredential)(nil)
6 changes: 4 additions & 2 deletions sdk/azidentity/client_certificate_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ func (c *ClientCertificateCredential) GetToken(ctx context.Context, opts azcore.
return tk, nil
}

// AuthenticationPolicy implements the azcore.Credential interface on ClientCertificateCredential.
func (c *ClientCertificateCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on ClientCertificateCredential.
func (c *ClientCertificateCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

var _ azcore.TokenCredential = (*ClientCertificateCredential)(nil)
4 changes: 2 additions & 2 deletions sdk/azidentity/client_certificate_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestClientCertificateCredential_CreateAuthRequestSuccess(t *testing.T) {
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatalf("Unexpected value for Content-Type header")
}
body, err := ioutil.ReadAll(req.Request.Body)
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestClientCertificateCredential_CreateAuthRequestSuccess_withCertificateCha
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatalf("Unexpected value for Content-Type header")
}
if len(cred.cert.publicCertificates) != 1 {
Expand Down
4 changes: 2 additions & 2 deletions sdk/azidentity/client_secret_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ func (c *ClientSecretCredential) GetToken(ctx context.Context, opts azcore.Token
return tk, nil
}

// AuthenticationPolicy implements the azcore.Credential interface on ClientSecretCredential and calls the Bearer Token policy
// NewAuthenticationPolicy implements the azcore.Credential interface on ClientSecretCredential and calls the Bearer Token policy
// to get the bearer token.
func (c *ClientSecretCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
func (c *ClientSecretCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

Expand Down
2 changes: 1 addition & 1 deletion sdk/azidentity/client_secret_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestClientSecretCredential_CreateAuthRequestSuccess(t *testing.T) {
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatalf("Unexpected value for Content-Type header")
}
body, err := ioutil.ReadAll(req.Request.Body)
Expand Down
6 changes: 3 additions & 3 deletions sdk/azidentity/device_code_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type DeviceCodeCredential struct {
tenantID string // Gets the Azure Active Directory tenant (directory) ID of the service principal
clientID string // Gets the client (application) ID of the service principal
userPrompt func(DeviceCodeMessage) // Sends the user a message with a verification URL and device code to sign in to the login server
refreshToken string // Gets the refresh token sent from the service and will be used to retreive new access tokens after the initial request for a token. Thread safety for updates is handled in the AuthenticationPolicy since only one goroutine will be updating at a time
refreshToken string // Gets the refresh token sent from the service and will be used to retreive new access tokens after the initial request for a token. Thread safety for updates is handled in the NewAuthenticationPolicy since only one goroutine will be updating at a time
}

// NewDeviceCodeCredential constructs a new DeviceCodeCredential used to authenticate against Azure Active Directory with a device code.
Expand Down Expand Up @@ -167,8 +167,8 @@ func (c *DeviceCodeCredential) GetToken(ctx context.Context, opts azcore.TokenRe
}
}

// AuthenticationPolicy implements the azcore.Credential interface on DeviceCodeCredential.
func (c *DeviceCodeCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on DeviceCodeCredential.
func (c *DeviceCodeCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/azidentity/device_code_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestDeviceCodeCredential_CreateAuthRequestSuccess(t *testing.T) {
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatalf("Unexpected value for Content-Type header")
}
body, err := ioutil.ReadAll(req.Request.Body)
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestDeviceCodeCredential_CreateAuthRequestCustomClientID(t *testing.T) {
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatalf("Unexpected value for Content-Type header")
}
body, err := ioutil.ReadAll(req.Request.Body)
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestDeviceCodeCredential_RequestNewDeviceCodeCustomTenantIDClientID(t *test
if err != nil {
t.Fatalf("Unexpectedly received an error: %v", err)
}
if req.Request.Header.Get(azcore.HeaderContentType) != azcore.HeaderURLEncoded {
if req.Request.Header.Get(headerContentType) != headerURLEncoded {
t.Fatalf("Unexpected value for Content-Type header")
}
body, err := ioutil.ReadAll(req.Request.Body)
Expand Down
4 changes: 2 additions & 2 deletions sdk/azidentity/environment_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ func (c *EnvironmentCredential) GetToken(ctx context.Context, opts azcore.TokenR
return c.cred.GetToken(ctx, opts)
}

// AuthenticationPolicy implements the azcore.Credential interface on EnvironmentCredential.
func (c *EnvironmentCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on EnvironmentCredential.
func (c *EnvironmentCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c.cred, options)
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/azidentity/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/Azure/azure-sdk-for-go/sdk/azidentity
go 1.14

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.0
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.17.0
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b
Expand Down
8 changes: 4 additions & 4 deletions sdk/azidentity/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.0 h1:4HBTI/9UDZN7tsXyB5TYP3xCv5xVHIUTbvHHH2HFxQY=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.0/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0 h1:HG1ggl8L3ZkV/Ydanf7lKr5kkhhPGCpWdnr1J6v7cO4=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.17.0 h1:j9ra6YGWu3TqNmCprpWYFCqQ3aizqujxrqhI7KLu6qg=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.17.0/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
4 changes: 2 additions & 2 deletions sdk/azidentity/interactive_browser_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func (c *InteractiveBrowserCredential) GetToken(ctx context.Context, opts azcore
return tk, nil
}

// AuthenticationPolicy implements the azcore.Credential interface on InteractiveBrowserCredential.
func (c *InteractiveBrowserCredential) AuthenticationPolicy(options azcore.AuthenticationPolicyOptions) azcore.Policy {
// NewAuthenticationPolicy implements the azcore.Credential interface on InteractiveBrowserCredential.
func (c *InteractiveBrowserCredential) NewAuthenticationPolicy(options azcore.AuthenticationOptions) azcore.Policy {
return newBearerTokenPolicy(c, options)
}

Expand Down
12 changes: 6 additions & 6 deletions sdk/azidentity/managed_identity_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (c *managedIdentityClient) createIMDSAuthRequest(ctx context.Context, id st
if err != nil {
return nil, err
}
request.Header.Set(azcore.HeaderMetadata, "true")
request.Header.Set(headerMetadata, "true")
q := request.URL.Query()
q.Add("api-version", c.imdsAPIVersion)
q.Add("resource", strings.Join(scopes, " "))
Expand Down Expand Up @@ -248,7 +248,7 @@ func (c *managedIdentityClient) getAzureArcSecretKey(ctx context.Context, resour
if err != nil {
return "", err
}
request.Header.Set(azcore.HeaderMetadata, "true")
request.Header.Set(headerMetadata, "true")
q := request.URL.Query()
q.Add("api-version", azureArcAPIVersion)
q.Add("resource", strings.Join(resources, " "))
Expand Down Expand Up @@ -284,8 +284,8 @@ func (c *managedIdentityClient) createAzureArcAuthRequest(ctx context.Context, k
if err != nil {
return nil, err
}
request.Header.Set(azcore.HeaderMetadata, "true")
request.Header.Set(azcore.HeaderAuthorization, fmt.Sprintf("Basic %s", key))
request.Header.Set(headerMetadata, "true")
request.Header.Set(headerAuthorization, fmt.Sprintf("Basic %s", key))
q := request.URL.Query()
q.Add("api-version", azureArcAPIVersion)
q.Add("resource", strings.Join(resources, " "))
Expand All @@ -298,15 +298,15 @@ func (c *managedIdentityClient) createCloudShellAuthRequest(ctx context.Context,
if err != nil {
return nil, err
}
request.Header.Set(azcore.HeaderMetadata, "true")
request.Header.Set(headerMetadata, "true")
data := url.Values{}
data.Set("resource", strings.Join(scopes, " "))
if clientID != "" {
data.Set(qpClientID, clientID)
}
dataEncoded := data.Encode()
body := azcore.NopCloser(strings.NewReader(dataEncoded))
if err := request.SetBody(body, azcore.HeaderURLEncoded); err != nil {
if err := request.SetBody(body, headerURLEncoded); err != nil {
return nil, err
}
return request, nil
Expand Down
Loading