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 @@ -12,9 +12,9 @@

from azure.core.tracing.decorator import distributed_trace
from azure.core.exceptions import HttpResponseError
from azure.core.pipeline.policies import BearerTokenCredentialPolicy

from ._chat_thread_client import ChatThreadClient
from ._common import CommunicationUserCredentialPolicy
from ._shared.user_credential import CommunicationUserCredential
from ._generated import AzureCommunicationChatService
from ._generated.models import CreateChatThreadRequest
Expand Down Expand Up @@ -75,7 +75,7 @@ def __init__(

self._client = AzureCommunicationChatService(
self._endpoint,
authentication_policy=CommunicationUserCredentialPolicy(self._credential),
authentication_policy=BearerTokenCredentialPolicy(self._credential),
sdk_moniker=SDK_MONIKER,
**kwargs
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from urlparse import urlparse # type: ignore

from azure.core.tracing.decorator import distributed_trace
from azure.core.pipeline.policies import BearerTokenCredentialPolicy

from ._shared.user_credential import CommunicationUserCredential
from ._common import CommunicationUserCredentialPolicy
from ._generated import AzureCommunicationChatService
from ._generated.models import (
AddChatThreadMembersRequest,
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(

self._client = AzureCommunicationChatService(
endpoint,
authentication_policy=CommunicationUserCredentialPolicy(self._credential),
authentication_policy=BearerTokenCredentialPolicy(self._credential),
sdk_moniker=SDK_MONIKER,
**kwargs
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

from ._communication_user_credential_policy import CommunicationUserCredentialPolicy


__all__ = [
'CommunicationUserCredentialPolicy'
]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Tuple,
)
import six

from msrest.serialization import TZ_UTC
from .utils import create_access_token

Expand Down Expand Up @@ -70,7 +71,6 @@ def get_token(self):
self._lock.notify_all()

raise

return self._token

def _wait_till_inprogress_thread_finish_refreshing(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
cast,
Tuple,
)

import six

from msrest.serialization import TZ_UTC
from .utils import create_access_token

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import base64
import json
import time
from typing import ( # pylint: disable=unused-import
cast,
Tuple,
Expand Down Expand Up @@ -65,6 +66,12 @@ def create_access_token(token):
try:
padded_base64_payload = base64.b64decode(parts[1] + "==").decode('ascii')
payload = json.loads(padded_base64_payload)
return AccessToken(token, datetime.fromtimestamp(payload['exp']).replace(tzinfo=TZ_UTC))
return AccessToken(token,
_convert_expires_on_datetime_to_utc_int(datetime.fromtimestamp(payload['exp']).replace(tzinfo=TZ_UTC)))
except ValueError:
raise ValueError(token_parse_err_msg)

def _convert_expires_on_datetime_to_utc_int(expires_on):
epoch = time.mktime(datetime(1970, 1, 1).timetuple())
return epoch-time.mktime(expires_on.timetuple())

Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import six
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.pipeline.policies import BearerTokenCredentialPolicy
from azure.core.exceptions import HttpResponseError
from azure.core.async_paging import AsyncItemPaged

from ._chat_thread_client_async import ChatThreadClient
from .._common import CommunicationUserCredentialPolicy
from .._shared.user_credential_async import CommunicationUserCredential
from .._generated.aio import AzureCommunicationChatService
from .._generated.models import (
Expand Down Expand Up @@ -78,7 +78,7 @@ def __init__(

self._client = AzureCommunicationChatService(
self._endpoint,
authentication_policy=CommunicationUserCredentialPolicy(self._credential),
authentication_policy=BearerTokenCredentialPolicy(self._credential),
sdk_moniker=SDK_MONIKER,
**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import six
from azure.core.tracing.decorator import distributed_trace
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.pipeline.policies import BearerTokenCredentialPolicy
from azure.core.async_paging import AsyncItemPaged

from .._common import CommunicationUserCredentialPolicy
from .._shared.user_credential_async import CommunicationUserCredential
from .._generated.aio import AzureCommunicationChatService
from .._generated.models import (
Expand Down Expand Up @@ -96,7 +96,7 @@ def __init__(

self._client = AzureCommunicationChatService(
endpoint,
authentication_policy=CommunicationUserCredentialPolicy(self._credential),
authentication_policy=BearerTokenCredentialPolicy(self._credential),
sdk_moniker=SDK_MONIKER,
**kwargs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interactions:
Content-Length:
- '0'
Date:
- Thu, 01 Oct 2020 22:48:04 GMT
- Wed, 02 Dec 2020 23:47:04 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
Expand All @@ -22,19 +22,19 @@ interactions:
body: '{"id": "sanitized"}'
headers:
api-supported-versions:
- 2020-07-20-preview1, 2020-07-20-preview2
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
content-type:
- application/json; charset=utf-8
date:
- Thu, 01 Oct 2020 22:48:04 GMT
- Wed, 02 Dec 2020 23:47:03 GMT
ms-cv:
- fe8GIULrmE6QhpXm1qICYQ.0
- y545XwThskuqneWPpI2J5g.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-processing-time:
- 226ms
- 206ms
status:
code: 200
message: OK
Expand All @@ -52,30 +52,30 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 01 Oct 2020 22:48:04 GMT
- Wed, 02 Dec 2020 23:47:05 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
- 'true'
method: POST
uri: https://sanitized.communication.azure.com/identities/sanitized/token?api-version=2020-07-20-preview2
response:
body: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-10-02T22:48:04.2945816+00:00"}'
body: '{"id": "sanitized", "token": "sanitized", "expiresOn": "2020-12-03T23:47:03.1417047+00:00"}'
headers:
api-supported-versions:
- 2020-07-20-preview1, 2020-07-20-preview2
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
content-type:
- application/json; charset=utf-8
date:
- Thu, 01 Oct 2020 22:48:04 GMT
- Wed, 02 Dec 2020 23:47:04 GMT
ms-cv:
- 1hqRr6NaHkKQuQschfqWGQ.0
- hsf4fi9k20SDG3oDg0ZUUA.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-processing-time:
- 292ms
- 283ms
status:
code: 200
message: OK
Expand All @@ -93,26 +93,26 @@ interactions:
Content-Type:
- application/json
User-Agent:
- azsdk-python-communication-chat/1.0.0b1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
- azsdk-python-communication-chat/1.0.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
method: POST
uri: https://sanitized.communication.azure.com/chat/threads?api-version=2020-09-21-preview2
response:
body: '{"multipleStatus": "sanitized"}'
headers:
api-supported-versions:
- 2020-09-21-preview2
- 2020-09-21-preview2, 2020-11-01-preview3
content-type:
- application/json; charset=utf-8
date:
- Thu, 01 Oct 2020 22:48:05 GMT
- Wed, 02 Dec 2020 23:47:04 GMT
ms-cv:
- uBNvvJKY+0Oh3CuI/A8sNQ.0
- cXxT3zNRQU+4EHUOWmcQ9w.0
strict-transport-security:
- max-age=2592000
transfer-encoding:
- chunked
x-processing-time:
- 181ms
- 215ms
status:
code: 207
message: Multi-Status
Expand All @@ -128,7 +128,7 @@ interactions:
Content-Length:
- '0'
Date:
- Thu, 01 Oct 2020 22:48:05 GMT
- Wed, 02 Dec 2020 23:47:06 GMT
User-Agent:
- azsdk-python-communication-administration/1.0.0b1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-return-client-request-id:
Expand All @@ -140,15 +140,15 @@ interactions:
string: ''
headers:
api-supported-versions:
- 2020-07-20-preview1, 2020-07-20-preview2
- 2020-01-15-preview3, 2020-07-20-preview1, 2020-07-20-preview2
date:
- Thu, 01 Oct 2020 22:48:06 GMT
- Wed, 02 Dec 2020 23:47:05 GMT
ms-cv:
- CyKTdQdMlk6bJqwL6tj9BQ.0
- FkccrBO7BEKSIxThg7d5bA.0
strict-transport-security:
- max-age=2592000
x-processing-time:
- 711ms
- 834ms
status:
code: 204
message: No Content
Expand All @@ -164,23 +164,23 @@ interactions:
Content-Length:
- '0'
User-Agent:
- azsdk-python-communication-chat/1.0.0b1 Python/3.8.5 (Windows-10-10.0.19041-SP0)
- azsdk-python-communication-chat/1.0.0b2 Python/3.8.5 (Windows-10-10.0.19041-SP0)
method: DELETE
uri: https://sanitized.communication.azure.com/chat/threads/sanitized?api-version=2020-09-21-preview2
response:
body:
string: ''
headers:
api-supported-versions:
- 2020-09-21-preview2
- 2020-09-21-preview2, 2020-11-01-preview3
date:
- Thu, 01 Oct 2020 22:48:06 GMT
- Wed, 02 Dec 2020 23:47:06 GMT
ms-cv:
- XTK1Jm4VZ0ibw36diC8kng.0
- z2W4cATUr0qN3rO0M3JG3Q.0
strict-transport-security:
- max-age=2592000
x-processing-time:
- 73ms
- 145ms
status:
code: 204
message: No Content
Expand Down
Loading