Skip to content

Commit 2499c06

Browse files
authored
Credentials return AccessToken by value (Azure#17838)
1 parent a8723e0 commit 2499c06

18 files changed

+101
-95
lines changed

sdk/azidentity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Removed `AuthorizationCodeCredential`. Use `InteractiveBrowserCredential` instead
1212
to authenticate a user with the authorization code flow.
1313
* Instances of `AuthenticationFailedError` are now returned by pointer.
14+
* `GetToken()` returns `azcore.AccessToken` by value
1415

1516
### Bugs Fixed
1617
* `AzureCLICredential` panics after receiving an unexpected error type

sdk/azidentity/azure_cli_credential.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,26 @@ func NewAzureCLICredential(options *AzureCLICredentialOptions) (*AzureCLICredent
6262

6363
// GetToken requests a token from the Azure CLI. This credential doesn't cache tokens, so every call invokes the CLI.
6464
// This method is called automatically by Azure SDK clients.
65-
func (c *AzureCLICredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (*azcore.AccessToken, error) {
65+
func (c *AzureCLICredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
6666
if len(opts.Scopes) != 1 {
67-
return nil, errors.New(credNameAzureCLI + ": GetToken() requires exactly one scope")
67+
return azcore.AccessToken{}, errors.New(credNameAzureCLI + ": GetToken() requires exactly one scope")
6868
}
6969
// CLI expects an AAD v1 resource, not a v2 scope
7070
scope := strings.TrimSuffix(opts.Scopes[0], defaultSuffix)
7171
at, err := c.authenticate(ctx, scope)
7272
if err != nil {
73-
return nil, err
73+
return azcore.AccessToken{}, err
7474
}
7575
logGetTokenSuccess(c, opts)
7676
return at, nil
7777
}
7878

7979
const timeoutCLIRequest = 10 * time.Second
8080

81-
func (c *AzureCLICredential) authenticate(ctx context.Context, resource string) (*azcore.AccessToken, error) {
81+
func (c *AzureCLICredential) authenticate(ctx context.Context, resource string) (azcore.AccessToken, error) {
8282
output, err := c.tokenProvider(ctx, resource, c.tenantID)
8383
if err != nil {
84-
return nil, err
84+
return azcore.AccessToken{}, err
8585
}
8686

8787
return c.createAccessToken(output)
@@ -137,7 +137,7 @@ func defaultTokenProvider() func(ctx context.Context, resource string, tenantID
137137
}
138138
}
139139

140-
func (c *AzureCLICredential) createAccessToken(tk []byte) (*azcore.AccessToken, error) {
140+
func (c *AzureCLICredential) createAccessToken(tk []byte) (azcore.AccessToken, error) {
141141
t := struct {
142142
AccessToken string `json:"accessToken"`
143143
Authority string `json:"_authority"`
@@ -152,15 +152,15 @@ func (c *AzureCLICredential) createAccessToken(tk []byte) (*azcore.AccessToken,
152152
}{}
153153
err := json.Unmarshal(tk, &t)
154154
if err != nil {
155-
return nil, err
155+
return azcore.AccessToken{}, err
156156
}
157157

158158
tokenExpirationDate, err := parseExpirationDate(t.ExpiresOn)
159159
if err != nil {
160-
return nil, fmt.Errorf("Error parsing Token Expiration Date %q: %+v", t.ExpiresOn, err)
160+
return azcore.AccessToken{}, fmt.Errorf("Error parsing Token Expiration Date %q: %+v", t.ExpiresOn, err)
161161
}
162162

163-
converted := &azcore.AccessToken{
163+
converted := azcore.AccessToken{
164164
Token: t.AccessToken,
165165
ExpiresOn: *tokenExpirationDate,
166166
}

sdk/azidentity/chained_token_credential.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func NewChainedTokenCredential(sources []azcore.TokenCredential, options *Chaine
5959

6060
// GetToken calls GetToken on the chained credentials in turn, stopping when one returns a token.
6161
// This method is called automatically by Azure SDK clients.
62-
func (c *ChainedTokenCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (*azcore.AccessToken, error) {
62+
func (c *ChainedTokenCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
6363
if !c.retrySources {
6464
// ensure only one goroutine at a time iterates the sources and perhaps sets c.successfulCredential
6565
c.cond.L.Lock()
@@ -80,7 +80,7 @@ func (c *ChainedTokenCredential) GetToken(ctx context.Context, opts policy.Token
8080

8181
var err error
8282
var errs []error
83-
var token *azcore.AccessToken
83+
var token azcore.AccessToken
8484
var successfulCredential azcore.TokenCredential
8585
for _, cred := range c.sources {
8686
token, err = cred.GetToken(ctx, opts)

sdk/azidentity/chained_token_credential_test.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
type fakeCredentialResponse struct {
20-
token *azcore.AccessToken
20+
token azcore.AccessToken
2121
err error
2222
}
2323

@@ -32,19 +32,19 @@ func NewFakeCredential() *fakeCredential {
3232
return &fakeCredential{mut: &sync.Mutex{}}
3333
}
3434

35-
func (c *fakeCredential) SetResponse(tk *azcore.AccessToken, err error) {
35+
func (c *fakeCredential) SetResponse(tk azcore.AccessToken, err error) {
3636
c.mut.Lock()
3737
defer c.mut.Unlock()
3838
c.static = &fakeCredentialResponse{tk, err}
3939
}
4040

41-
func (c *fakeCredential) AppendResponse(tk *azcore.AccessToken, err error) {
41+
func (c *fakeCredential) AppendResponse(tk azcore.AccessToken, err error) {
4242
c.mut.Lock()
4343
defer c.mut.Unlock()
4444
c.responses = append(c.responses, fakeCredentialResponse{tk, err})
4545
}
4646

47-
func (c *fakeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (token *azcore.AccessToken, err error) {
47+
func (c *fakeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
4848
c.mut.Lock()
4949
defer c.mut.Unlock()
5050
c.getTokenCalls += 1
@@ -56,7 +56,7 @@ func (c *fakeCredential) GetToken(ctx context.Context, opts policy.TokenRequestO
5656
return response.token, response.err
5757
}
5858

59-
func testGoodGetTokenResponse(t *testing.T, token *azcore.AccessToken, err error) {
59+
func testGoodGetTokenResponse(t *testing.T, token azcore.AccessToken, err error) {
6060
if err != nil {
6161
t.Fatal(err)
6262
}
@@ -81,9 +81,9 @@ func TestChainedTokenCredential_NilSource(t *testing.T) {
8181

8282
func TestChainedTokenCredential_GetTokenSuccess(t *testing.T) {
8383
c1 := NewFakeCredential()
84-
c1.SetResponse(nil, newCredentialUnavailableError("test", "something went wrong"))
84+
c1.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("test", "something went wrong"))
8585
c2 := NewFakeCredential()
86-
c2.SetResponse(&azcore.AccessToken{Token: tokenValue, ExpiresOn: time.Now().Add(time.Hour)}, nil)
86+
c2.SetResponse(azcore.AccessToken{Token: tokenValue, ExpiresOn: time.Now().Add(time.Hour)}, nil)
8787
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{c1, c2}, nil)
8888
if err != nil {
8989
t.Fatal(err)
@@ -108,7 +108,7 @@ func TestChainedTokenCredential_GetTokenSuccess(t *testing.T) {
108108

109109
func TestChainedTokenCredential_GetTokenFail(t *testing.T) {
110110
c := NewFakeCredential()
111-
c.SetResponse(nil, newAuthenticationFailedError("test", "something went wrong", nil))
111+
c.SetResponse(azcore.AccessToken{}, newAuthenticationFailedError("test", "something went wrong", nil))
112112
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{c}, nil)
113113
if err != nil {
114114
t.Fatal(err)
@@ -128,11 +128,11 @@ func TestChainedTokenCredential_GetTokenFail(t *testing.T) {
128128

129129
func TestChainedTokenCredential_MultipleCredentialsGetTokenUnavailable(t *testing.T) {
130130
c1 := NewFakeCredential()
131-
c1.SetResponse(nil, newCredentialUnavailableError("unavailableCredential1", "Unavailable expected error"))
131+
c1.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("unavailableCredential1", "Unavailable expected error"))
132132
c2 := NewFakeCredential()
133-
c2.SetResponse(nil, newCredentialUnavailableError("unavailableCredential2", "Unavailable expected error"))
133+
c2.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("unavailableCredential2", "Unavailable expected error"))
134134
c3 := NewFakeCredential()
135-
c3.SetResponse(nil, newCredentialUnavailableError("unavailableCredential3", "Unavailable expected error"))
135+
c3.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("unavailableCredential3", "Unavailable expected error"))
136136
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{c1, c2, c3}, nil)
137137
if err != nil {
138138
t.Fatal(err)
@@ -157,11 +157,11 @@ Attempted credentials:
157157

158158
func TestChainedTokenCredential_MultipleCredentialsGetTokenAuthenticationFailed(t *testing.T) {
159159
c1 := NewFakeCredential()
160-
c1.SetResponse(nil, newCredentialUnavailableError("unavailableCredential1", "Unavailable expected error"))
160+
c1.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("unavailableCredential1", "Unavailable expected error"))
161161
c2 := NewFakeCredential()
162-
c2.SetResponse(nil, newCredentialUnavailableError("unavailableCredential2", "Unavailable expected error"))
162+
c2.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("unavailableCredential2", "Unavailable expected error"))
163163
c3 := NewFakeCredential()
164-
c3.SetResponse(nil, newAuthenticationFailedError("authenticationFailedCredential3", "Authentication failed expected error", nil))
164+
c3.SetResponse(azcore.AccessToken{}, newAuthenticationFailedError("authenticationFailedCredential3", "Authentication failed expected error", nil))
165165
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{c1, c2, c3}, nil)
166166
if err != nil {
167167
t.Fatal(err)
@@ -186,7 +186,7 @@ Attempted credentials:
186186

187187
func TestChainedTokenCredential_MultipleCredentialsGetTokenCustomName(t *testing.T) {
188188
c := NewFakeCredential()
189-
c.SetResponse(nil, newCredentialUnavailableError("unavailableCredential1", "Unavailable expected error"))
189+
c.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("unavailableCredential1", "Unavailable expected error"))
190190
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{c}, nil)
191191
if err != nil {
192192
t.Fatal(err)
@@ -210,9 +210,9 @@ Attempted credentials:
210210

211211
func TestChainedTokenCredential_RepeatedGetTokenWithSuccessfulCredential(t *testing.T) {
212212
failedCredential := NewFakeCredential()
213-
failedCredential.SetResponse(nil, newCredentialUnavailableError("MockCredential", "Mocking a credential unavailable error"))
213+
failedCredential.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("MockCredential", "Mocking a credential unavailable error"))
214214
successfulCredential := NewFakeCredential()
215-
successfulCredential.SetResponse(&azcore.AccessToken{Token: tokenValue, ExpiresOn: time.Now()}, nil)
215+
successfulCredential.SetResponse(azcore.AccessToken{Token: tokenValue, ExpiresOn: time.Now()}, nil)
216216

217217
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{failedCredential, successfulCredential}, nil)
218218
if err != nil {
@@ -241,9 +241,9 @@ func TestChainedTokenCredential_RepeatedGetTokenWithSuccessfulCredential(t *test
241241

242242
func TestChainedTokenCredential_RepeatedGetTokenWithSuccessfulCredentialWithRetrySources(t *testing.T) {
243243
failedCredential := NewFakeCredential()
244-
failedCredential.SetResponse(nil, newCredentialUnavailableError("MockCredential", "Mocking a credential unavailable error"))
244+
failedCredential.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("MockCredential", "Mocking a credential unavailable error"))
245245
successfulCredential := NewFakeCredential()
246-
successfulCredential.SetResponse(&azcore.AccessToken{Token: tokenValue, ExpiresOn: time.Now()}, nil)
246+
successfulCredential.SetResponse(azcore.AccessToken{Token: tokenValue, ExpiresOn: time.Now()}, nil)
247247

248248
cred, err := NewChainedTokenCredential([]azcore.TokenCredential{failedCredential, successfulCredential}, &ChainedTokenCredentialOptions{RetrySources: true})
249249
if err != nil {
@@ -272,11 +272,11 @@ func TestChainedTokenCredential_RepeatedGetTokenWithSuccessfulCredentialWithRetr
272272

273273
func TestChainedTokenCredential_Race(t *testing.T) {
274274
successFake := NewFakeCredential()
275-
successFake.SetResponse(&azcore.AccessToken{Token: "*", ExpiresOn: time.Now().Add(time.Hour)}, nil)
275+
successFake.SetResponse(azcore.AccessToken{Token: "*", ExpiresOn: time.Now().Add(time.Hour)}, nil)
276276
authFailFake := NewFakeCredential()
277-
authFailFake.SetResponse(nil, newAuthenticationFailedError("", "", nil))
277+
authFailFake.SetResponse(azcore.AccessToken{}, newAuthenticationFailedError("", "", nil))
278278
unavailableFake := NewFakeCredential()
279-
unavailableFake.SetResponse(nil, newCredentialUnavailableError("", ""))
279+
unavailableFake.SetResponse(azcore.AccessToken{}, newCredentialUnavailableError("", ""))
280280
tro := policy.TokenRequestOptions{Scopes: []string{liveTestScope}}
281281

282282
for _, b := range []bool{true, false} {

sdk/azidentity/client_certificate_credential.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,22 @@ func NewClientCertificateCredential(tenantID string, clientID string, certs []*x
8080
}
8181

8282
// GetToken requests an access token from Azure Active Directory. This method is called automatically by Azure SDK clients.
83-
func (c *ClientCertificateCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (*azcore.AccessToken, error) {
83+
func (c *ClientCertificateCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
8484
if len(opts.Scopes) == 0 {
85-
return nil, errors.New(credNameCert + ": GetToken() requires at least one scope")
85+
return azcore.AccessToken{}, errors.New(credNameCert + ": GetToken() requires at least one scope")
8686
}
8787
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes)
8888
if err == nil {
8989
logGetTokenSuccess(c, opts)
90-
return &azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
90+
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
9191
}
9292

9393
ar, err = c.client.AcquireTokenByCredential(ctx, opts.Scopes)
9494
if err != nil {
95-
return nil, newAuthenticationFailedErrorFromMSALError(credNameCert, err)
95+
return azcore.AccessToken{}, newAuthenticationFailedErrorFromMSALError(credNameCert, err)
9696
}
9797
logGetTokenSuccess(c, opts)
98-
return &azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
98+
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
9999
}
100100

101101
// ParseCertificates loads certificates and a private key, in PEM or PKCS12 format, for use with NewClientCertificateCredential.

sdk/azidentity/client_certificate_credential_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"log"
1212
"os"
13+
"reflect"
1314
"testing"
1415

1516
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
@@ -229,8 +230,8 @@ func TestClientCertificateCredential_InvalidCertLive(t *testing.T) {
229230
}
230231

231232
tk, err := cred.GetToken(context.Background(), policy.TokenRequestOptions{Scopes: []string{liveTestScope}})
232-
if tk != nil {
233-
t.Fatal("GetToken returned a token")
233+
if !reflect.ValueOf(tk).IsZero() {
234+
t.Fatal("expected a zero value AccessToken")
234235
}
235236
var e *AuthenticationFailedError
236237
if !errors.As(err, &e) {

sdk/azidentity/client_secret_credential.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@ func NewClientSecretCredential(tenantID string, clientID string, clientSecret st
5252
}
5353

5454
// GetToken requests an access token from Azure Active Directory. This method is called automatically by Azure SDK clients.
55-
func (c *ClientSecretCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (*azcore.AccessToken, error) {
55+
func (c *ClientSecretCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
5656
if len(opts.Scopes) == 0 {
57-
return nil, errors.New(credNameSecret + ": GetToken() requires at least one scope")
57+
return azcore.AccessToken{}, errors.New(credNameSecret + ": GetToken() requires at least one scope")
5858
}
5959
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes)
6060
if err == nil {
6161
logGetTokenSuccess(c, opts)
62-
return &azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
62+
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
6363
}
6464

6565
ar, err = c.client.AcquireTokenByCredential(ctx, opts.Scopes)
6666
if err != nil {
67-
return nil, newAuthenticationFailedErrorFromMSALError(credNameSecret, err)
67+
return azcore.AccessToken{}, newAuthenticationFailedErrorFromMSALError(credNameSecret, err)
6868
}
6969
logGetTokenSuccess(c, opts)
70-
return &azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
70+
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
7171
}
7272

7373
var _ azcore.TokenCredential = (*ClientSecretCredential)(nil)

sdk/azidentity/client_secret_credential_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package azidentity
66
import (
77
"context"
88
"errors"
9+
"reflect"
910
"testing"
1011

1112
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
@@ -55,8 +56,8 @@ func TestClientSecretCredential_InvalidSecretLive(t *testing.T) {
5556
t.Fatalf("failed to construct credential: %v", err)
5657
}
5758
tk, err := cred.GetToken(context.Background(), policy.TokenRequestOptions{Scopes: []string{liveTestScope}})
58-
if tk != nil {
59-
t.Fatal("GetToken returned a token")
59+
if !reflect.ValueOf(tk).IsZero() {
60+
t.Fatal("expected a zero value AccessToken")
6061
}
6162
var e *AuthenticationFailedError
6263
if !errors.As(err, &e) {

sdk/azidentity/default_azure_credential.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func NewDefaultAzureCredential(options *DefaultAzureCredentialOptions) (*Default
9090
}
9191

9292
// GetToken requests an access token from Azure Active Directory. This method is called automatically by Azure SDK clients.
93-
func (c *DefaultAzureCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (token *azcore.AccessToken, err error) {
93+
func (c *DefaultAzureCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
9494
return c.chain.GetToken(ctx, opts)
9595
}
9696

@@ -119,11 +119,11 @@ type defaultCredentialErrorReporter struct {
119119
err error
120120
}
121121

122-
func (d *defaultCredentialErrorReporter) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (token *azcore.AccessToken, err error) {
122+
func (d *defaultCredentialErrorReporter) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
123123
if _, ok := d.err.(*credentialUnavailableError); ok {
124-
return nil, d.err
124+
return azcore.AccessToken{}, d.err
125125
}
126-
return nil, newCredentialUnavailableError(d.credType, d.err.Error())
126+
return azcore.AccessToken{}, newCredentialUnavailableError(d.credType, d.err.Error())
127127
}
128128

129129
var _ azcore.TokenCredential = (*defaultCredentialErrorReporter)(nil)

sdk/azidentity/device_code_credential.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,33 @@ func NewDeviceCodeCredential(options *DeviceCodeCredentialOptions) (*DeviceCodeC
9595

9696
// GetToken requests an access token from Azure Active Directory. It will begin the device code flow and poll until the user completes authentication.
9797
// This method is called automatically by Azure SDK clients.
98-
func (c *DeviceCodeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (*azcore.AccessToken, error) {
98+
func (c *DeviceCodeCredential) GetToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
9999
if len(opts.Scopes) == 0 {
100-
return nil, errors.New(credNameDeviceCode + ": GetToken() requires at least one scope")
100+
return azcore.AccessToken{}, errors.New(credNameDeviceCode + ": GetToken() requires at least one scope")
101101
}
102102
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, public.WithSilentAccount(c.account))
103103
if err == nil {
104-
return &azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
104+
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
105105
}
106106
dc, err := c.client.AcquireTokenByDeviceCode(ctx, opts.Scopes)
107107
if err != nil {
108-
return nil, newAuthenticationFailedErrorFromMSALError(credNameDeviceCode, err)
108+
return azcore.AccessToken{}, newAuthenticationFailedErrorFromMSALError(credNameDeviceCode, err)
109109
}
110110
err = c.userPrompt(ctx, DeviceCodeMessage{
111111
UserCode: dc.Result.UserCode,
112112
VerificationURL: dc.Result.VerificationURL,
113113
Message: dc.Result.Message,
114114
})
115115
if err != nil {
116-
return nil, err
116+
return azcore.AccessToken{}, err
117117
}
118118
ar, err = dc.AuthenticationResult(ctx)
119119
if err != nil {
120-
return nil, newAuthenticationFailedErrorFromMSALError(credNameDeviceCode, err)
120+
return azcore.AccessToken{}, newAuthenticationFailedErrorFromMSALError(credNameDeviceCode, err)
121121
}
122122
c.account = ar.Account
123123
logGetTokenSuccess(c, opts)
124-
return &azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
124+
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
125125
}
126126

127127
var _ azcore.TokenCredential = (*DeviceCodeCredential)(nil)

0 commit comments

Comments
 (0)