8000 OAuthScope parity with JS and DotNet (#2093) · GitDakky/botbuilder-python@48ba78e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 48ba78e

Browse files
tracyboehrerTracy Boehrer
and
Tracy Boehrer
authored
OAuthScope parity with JS and DotNet (microsoft#2093)
* OAuthScope parity with JS and DotNet * black formatting --------- Co-authored-by: Tracy Boehrer <trboehre@microsoft.com>
1 parent 9b6f0e6 commit 48ba78e

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

libraries/botframework-connector/botframework/connector/auth/authentication_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AuthenticationConstants(ABC):
2222
DEFAULT_CHANNEL_AUTH_TENANT = "botframework.com"
2323

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

2727
# TO BOT FROM CHANNEL: Token issuer
2828
TO_BOT_FROM_CHANNEL_TOKEN_ISSUER = "https://api.botframework.com"

libraries/botframework-connector/botframework/connector/auth/government_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class GovernmentConstants(ABC):
3131
"""
3232
TO CHANNEL FROM BOT: OAuth scope to request
3333
"""
34-
TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.us/.default"
34+
TO_CHANNEL_FROM_BOT_OAUTH_SCOPE = "https://api.botframework.us"
3535

3636
"""
3737
TO BOT FROM CHANNEL: Token issuer

libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ def __init__(
3030
self.microsoft_app_password = password
3131
self.app = None
3232

33-
# This check likely needs to be more nuanced than this. Assuming
34- # "/.default" precludes other valid suffixes
35-
scope = self.oauth_scope
36-
if oauth_scope and not scope.endswith("/.default"):
37-
scope += "/.default"
38-
self.scopes = [scope]
39-
4033
@staticmethod
4134
def empty():
4235
return MicrosoftAppCredentials("", "")
@@ -47,17 +40,18 @@ def get_access_token(self, force_refresh: bool = False) -> str:
4740
:return: The access token for the given app id and password.
4841
"""
4942

43+
scope = self.oauth_scope
44+
if not scope.endswith("/.default"):
45+
scope += "/.default"
46+
scopes = [scope]
47+
5048
# Firstly, looks up a token from cache
5149
# Since we are looking for token for the current app, NOT for an end user,
5250
# notice we give account parameter as None.
53-
auth_token = self.__get_msal_app().acquire_token_silent(
54-
self.scopes, account=None
55-
)
51+
auth_token = self.__get_msal_app().acquire_token_silent(scopes, account=None)
5652
if not auth_token:
5753
# No suitable token exists in cache. Let's get a new one from AAD.
58-
auth_token = self.__get_msal_app().acquire_token_for_client(
59-
scopes=self.scopes
60-
)
54+
auth_token = self.__get_msal_app().acquire_token_for_client(scopes=scopes)
6155
return auth_token["access_token"]
6256

6357
def __get_msal_app(self):

0 commit comments

Comments
 (0)
0