Skip to content
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
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ def get_refresh_token(self, resource=CLOUD.endpoints.active_directory_resource_i
if user_type == _USER:
_, _, token_entry = self._creds_cache.retrieve_token_for_user(
username_or_sp_id, account[_TENANT_ID], resource)
return None, token_entry[_REFRESH_TOKEN], str(account[_TENANT_ID])
return None, token_entry[_REFRESH_TOKEN], token_entry[_ACCESS_TOKEN], str(account[_TENANT_ID])

sp_secret = self._creds_cache.retrieve_secret_of_service_principal(username_or_sp_id)
return username_or_sp_id, sp_secret, str(account[_TENANT_ID])
return username_or_sp_id, sp_secret, None, str(account[_TENANT_ID])

def get_raw_token(self, resource=CLOUD.endpoints.active_directory_resource_id,
subscription=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ def _get_login_token(login_server, only_refresh_token=True, repository=None):

from azure.cli.core._profile import Profile
profile = Profile()
sp_id, refresh, tenant = profile.get_refresh_token()
sp_id, refresh, access, tenant = profile.get_refresh_token()

headers = {'Content-Type': 'application/x-www-form-urlencoded'}
if sp_id is None:
content = {
'grant_type': 'refresh_token',
'grant_type': 'access_token_refresh_token',
'service': params['service'],
'tenant': tenant,
'access_token': access,
Copy link

Choose a reason for hiding this comment

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

Do we need to send both access and refresh tokens or just either one of them? Just some NIT comments: If it is either one of them, can we make grant_type explicitly access_token or refresh_token so it would be clear what I am sending and what I will receive back? Then we can have one token field which can be access or refresh token.

Copy link
Author

Choose a reason for hiding this comment

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

We'll need to send both.

'refresh_token': refresh
}
else:
Expand Down