Do not require refresh token to obtain ACR token. Especially this will make the ACR auto-login feature work with Service Principal login, that does not have a refresh token

Signed-off-by: Guillaume Tardif <guillaume.tardif@docker.com>
This commit is contained in:
Guillaume Tardif 2020-08-19 13:56:41 +02:00
parent 2bb5614501
commit 04c678b099
1 changed files with 2 additions and 3 deletions

View File

@ -150,10 +150,9 @@ func (c cliRegistryHelper) autoLoginAcr(registry string) error {
} }
data := url.Values{ data := url.Values{
"grant_type": {"access_token_refresh_token"}, "grant_type": {"access_token"},
"service": {registry}, "service": {registry},
"tenant": {tenantID}, "tenant": {tenantID},
"refresh_token": {token.RefreshToken},
"access_token": {token.AccessToken}, "access_token": {token.AccessToken},
} }
repoAuthURL := fmt.Sprintf("https://%s/oauth2/exchange", registry) repoAuthURL := fmt.Sprintf("https://%s/oauth2/exchange", registry)
@ -162,7 +161,7 @@ func (c cliRegistryHelper) autoLoginAcr(registry string) error {
return err return err
} }
if res.StatusCode != 200 { if res.StatusCode != 200 {
return errors.Errorf("error while renewing access token, status : %s", res.Status) return errors.Errorf("error while accessing ACR token from Azure login, status : %s", res.Status)
} }
bits, err := ioutil.ReadAll(res.Body) bits, err := ioutil.ReadAll(res.Body)
if err != nil { if err != nil {