code: func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
  	logrus.Debugf("attempting v2 login to registry endpoint %s", strings.TrimRight(endpoint.URL.String(), "/")+"/v2/")
  
  	modifiers := Headers(userAgent, nil)
  	authTransport := transport.NewTransport(NewTransport(endpoint.TLSConfig), modifiers...)
  
  	credentialAuthConfig := *authConfig
  	creds := loginCredentialStore{
  		authConfig: &credentialAuthConfig,
  	}
  
  	loginClient, foundV2, err := v2AuthHTTPClient(endpoint.URL, authTransport, modifiers, creds, nil)
  	if err != nil {
  		return "", "", err
  	}
  
  	endpointStr := strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
  	req, err := http.NewRequest("GET", endpointStr, nil)
  	if err != nil {
  		if !foundV2 {
  			err = fallbackError{err: err}
  		}
  		return "", "", err
  	}
  
  	resp, err := loginClient.Do(req)
  	if err != nil {
  		err = translateV2AuthError(err)
  		if !foundV2 {
  			err = fallbackError{err: err}
  		}
  
  		return "", "", err
  	}
  	defer resp.Body.Close()
  
  	if resp.StatusCode == http.StatusOK {
  		return "Login Succeeded", credentialAuthConfig.IdentityToken, nil
  	}
  
  	// TODO(dmcgowan): Attempt to further interpret result, status code and error code string
  	err = errors.Errorf("login attempt to %s failed with status: %d %s", endpointStr, resp.StatusCode, http.StatusText(resp.StatusCode))
  	if !foundV2 {
  		err = fallbackError{err: err}
  	}
  	return "", "", err
  }
docs: // loginV2 tries to login to the v2 registry server. The given registry
  // endpoint will be pinged to get authorization challenges. These challenges
  // will be used to authenticate against the registry to validate credentials.