Repository: microsoft/botbuilder-python

Issue:
[PORT] Updated MicrosoftGovernmentAppCredentials to support Skills in Azure Gov
> Port this change from botbuilder-dotnet/master branch:
https://github.com/microsoft/botbuilder-dotnet/pull/3353

Fixes https://github.com/microsoft/botbuilder-dotnet/issues/3233

Added constructor to MicrosoftGovernmentAppCredentials that takes OAuthScope to support skills in gov.
Updated BotFrameworkHttpClient and BotFrameworkAdapter to pass the OAuthScope to MicrosoftGovernmentAppCredentials
Added SimpleBotToBot functional test for testing.
Added Microsoft.Bot.Framework.Skills.sln to load skills test projects.


# Changed projects
* Microsoft.Bot.Builder
* Microsoft.Bot.Connector
* integration
* Microsoft.Bot.Connector.Tests

[Skills]





Discussion:
Blocked by lack of Gov support for Python.
Most of these changes have already been made.  Excluding the functional tests which Python has limited support for right now.

BotFrameworkHttpClient._get_app_credentials might be doing the correct thing.  Needs to be double checked, and switch to using MicrosoftGovernmentAppCredentials.

Resolving patch:
diff --git a/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py b/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
--- a/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
+++ b/libraries/botbuilder-integration-aiohttp/botbuilder/integration/aiohttp/bot_framework_http_client.py
@@ -18,8 +18,9 @@
 from botframework.connector.auth import (
     ChannelProvider,
     CredentialProvider,
-    GovernmentConstants,
     MicrosoftAppCredentials,
+    AppCredentials,
+    MicrosoftGovernmentAppCredentials,
 )
 
 
@@ -146,27 +147,26 @@ async def post_buffered_activity(
 
     async def _get_app_credentials(
         self, app_id: str, oauth_scope: str
-    ) -> MicrosoftAppCredentials:
+    ) -> AppCredentials:
         if not app_id:
-            return MicrosoftAppCredentials(None, None)
+            return MicrosoftAppCredentials.empty()
 
+        # in the cache?
         cache_key = f"{app_id}{oauth_scope}"
         app_credentials = BotFrameworkHttpClient._APP_CREDENTIALS_CACHE.get(cache_key)
-
         if app_credentials:
             return app_credentials
 
+        # create a new AppCredentials
         app_password = await self._credential_provider.get_app_password(app_id)
-        app_credentials = MicrosoftAppCredentials(
-            app_id, app_password, oauth_scope=oauth_scope
+
+        app_credentials = (
+            MicrosoftGovernmentAppCredentials(app_id, app_password, scope=oauth_scope)
+            if self._credential_provider and self._channel_provider.is_government()
+            else MicrosoftAppCredentials(app_id, app_password, oauth_scope=oauth_scope)
         )
-        if self._channel_provider and self._channel_provider.is_government():
-            app_credentials.oauth_endpoint = (
-                GovernmentConstants.TO_CHANNEL_FROM_BOT_LOGIN_URL
-            )
-            app_credentials.oauth_scope = (
-                GovernmentConstants.TO_CHANNEL_FROM_BOT_OAUTH_SCOPE
-            )
 
+        # put it in the cache
         BotFrameworkHttpClient._APP_CREDENTIALS_CACHE[cache_key] = app_credentials
+
         return app_credentials
diff --git a/libraries/botframework-connector/botframework/connector/auth/microsoft_government_app_credentials.py b/libraries/botframework-connector/botframework/connector/auth/microsoft_government_app_credentials.py
--- a/libraries/botframework-connector/botframework/connector/auth/microsoft_government_app_credentials.py
+++ b/libraries/botframework-connector/botframework/connector/auth/microsoft_government_app_credentials.py
@@ -14,10 +14,13 @@ def __init__(
         app_id: str,
         app_password: str,
         channel_auth_tenant: str = None,
-        scope: str = GovernmentConstants.TO_CHANNEL_FROM_BOT_OAUTH_SCOPE,
+        scope: str = None,
     ):
         super().__init__(app_id, app_password, channel_auth_tenant, scope)
         self.oauth_endpoint = GovernmentConstants.TO_CHANNEL_FROM_BOT_LOGIN_URL
+        self.oauth_scope = (
+            scope if scope else GovernmentConstants.TO_CHANNEL_FROM_BOT_OAUTH_SCOPE
+        )
 
     @staticmethod
     def empty():


Test patch: