Skip to content

Acquiring token silently with account set to None fails in Azure Government #223

@marlonsingleton

Description

@marlonsingleton

Describe the bug
A clear and concise description of what the bug is.

UPDATE by Ray: There is also an internal issue created here, which is currently under investigation by our service side team.

To Reproduce
Steps to reproduce the behavior:

  1. Go to our off-the-shelf samples and pick one that is closest to your usage scenario. You should not need to modify the sample.
  2. Follow the description of the sample, typically at the beginning of it, to prepare a config.json containing your test configurations
  3. Run such sample, typically by python sample.py config.json
  4. See the error
  5. In this bug report, tell us the sample you choose, paste the content of the config.json with your test setup (which you can choose to skip your credentials, and/or mail it to our developer's email).
import msal
import os
import sys
from pprint import pprint

SCOPES = ["https://graph.microsoft.us/.default"]

app = msal.ConfidentialClientApplication(
    client_id="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    client_credential=['CLIENT_SECRET'],
    authority='https://login.microsoftonline.us/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
)

result = app.acquire_token_silent(scopes=SCOPES, account=None)
if not result:
    result = app.acquire_token_for_client(scopes=SCOPES)

if 'access_token' not in result:
    msg = "Could not acquire Azure access token: {error}: {descr}".format(
        error=result.get('error'),
        descr=result.get('error_description'),
    )
    pprint(msg)
    sys.exit(1)

pprint("Finished")
pprint(result)

Expected behavior

#result should equal None, evaluate if statement then acquire token for client
#works as expected in Azure Public cloud

result = app.acquire_token_silent(scopes=SCOPES, account=None)
if not result:
    result = app.acquire_token_for_client(scopes=SCOPES)

What you see instead

Traceback starts with:
 httplib_response = self._make_request(

Traceback ends with:
(Caused by SSLError(SSLCertVerificationError("hostname 'login.usgovcloudapi.net' doesn't match either of 'graph.aadg.microsoftonline.us', '*.b2clogin.us'")))

The MSAL Python version you are using
Paste the output of this
python -c "import msal; print(msal.__version__)"
MSAL version '1.4.1'

Additional context
Add any other context about the problem here.

#This returns token without issue

#result = app.acquire_token_silent(scopes=SCOPES, account=None)
#if not result:
result = app.acquire_token_for_client(scopes=SCOPES)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions