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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AuthenticationConstants(ABC):
DEFAULT_CHANNEL_AUTH_TENANT = "botframework.com"

# TO CHANNEL FROM BOT: OAuth scope to request
TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.com/.default"
TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.com"

# TO BOT FROM CHANNEL: Token issuer
TO_BOT_FROM_CHANNEL_TOKEN_ISSUER = "https://api.botframework.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GovernmentConstants(ABC):
"""
TO CHANNEL FROM BOT: OAuth scope to request
"""
TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.us/.default"
TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.us"

"""
TO BOT FROM CHANNEL: Token issuer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ def __init__(
self.microsoft_app_password = password
self.app = None

# This check likely needs to be more nuanced than this. Assuming
# "/.default" precludes other valid suffixes
scope = self.oauth_scope
if oauth_scope and not scope.endswith("/.default"):
scope += "/.default"
self.scopes = [scope]

@staticmethod
def empty():
return MicrosoftAppCredentials("", "")
Expand All @@ -47,17 +40,18 @@ def get_access_token(self, force_refresh: bool = False) -> str:
:return: The access token for the given app id and password.
"""

scope = self.oauth_scope
if not scope.endswith("/.default"):
scope += "/.default"
scopes = [scope]

# Firstly, looks up a token from cache
# Since we are looking for token for the current app, NOT for an end user,
# notice we give account parameter as None.
auth_token = self.__get_msal_app().acquire_token_silent(
self.scopes, account=None
)
auth_token = self.__get_msal_app().acquire_token_silent(scopes, account=None)
if not auth_token:
# No suitable token exists in cache. Let's get a new one from AAD.
auth_token = self.__get_msal_app().acquire_token_for_client(
scopes=self.scopes
)
auth_token = self.__get_msal_app().acquire_token_for_client(scopes=scopes)
return auth_token["access_token"]

def __get_msal_app(self):
Expand Down