Skip to content

Commit

Permalink
Renaming with_token identity function
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge-beauregard committed Mar 3, 2021
1 parent 303ff1f commit e0d33fc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions sdk/communication/azure-communication-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ user = identity_client.create_user()
print("User created with id:" + user.identifier)
```

Alternatively, use the `create_user_with_token` method to create a new user and issue a token for it.\
Alternatively, use the `create_user_and_token` method to create a new user and issue a token for it.\
For this option, a list of `CommunicationTokenScope` must be defined (see "Issuing an access token" for more information)

```python
user, tokenresponse = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User id:" + user.identifier)
print("Token issued with value: " + tokenresponse.token)
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def create_user(self, **kwargs):
**kwargs)

@distributed_trace
def create_user_with_token(
def create_user_and_token(
self,
scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]]
**kwargs # type: Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def create_user(self, **kwargs):
**kwargs)

@distributed_trace_async
async def create_user_with_token(
async def create_user_and_token(
self,
scopes, # type: List[Union[str, "_model.CommunicationTokenScope"]]
**kwargs # type: Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def create_user(self):
user = identity_client.create_user()
print("User created with id:" + user.identifier)

def create_user_with_token(self):
def create_user_and_token(self):
from azure.communication.identity import (
CommunicationIdentityClient,
CommunicationTokenScope
Expand All @@ -84,7 +84,7 @@ def create_user_with_token(self):
else:
identity_client = CommunicationIdentityClient.from_connection_string(self.connection_string)
print("Creating new user with token")
user, tokenresponse = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, tokenresponse = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User created with id:" + user.identifier)
print("Token issued with value: " + tokenresponse.token)

Expand All @@ -104,7 +104,7 @@ def delete_user(self):
if __name__ == '__main__':
sample = CommunicationIdentityClientSamples()
sample.create_user()
sample.create_user_with_token()
sample.create_user_and_token()
sample.get_token()
sample.revoke_tokens()
sample.delete_user()
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def create_user(self):
user = await identity_client.create_user()
print("User created with id:" + user.identifier)

async def create_user_with_token(self):
async def create_user_and_token(self):
from azure.communication.identity.aio import CommunicationIdentityClient
from azure.communication.identity import CommunicationTokenScope
if self.client_id is not None and self.client_secret is not None and self.tenant_id is not None:
Expand All @@ -86,7 +86,7 @@ async def create_user_with_token(self):

async with identity_client:
print("Creating new user with token")
user, tokenresponse = await identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, tokenresponse = await identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])
print("User created with id:" + user.identifier)
print("Token issued with value: " + tokenresponse.token)

Expand All @@ -107,7 +107,7 @@ async def delete_user(self):
async def main():
sample = CommunicationIdentityClientSamples()
await sample.create_user()
await sample.create_user_with_token()
await sample.create_user_and_token()
await sample.get_token()
await sample.revoke_tokens()
await sample.delete_user()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def test_create_user(self, connection_string):

@ResourceGroupPreparer(random_name_enabled=True)
@CommunicationServicePreparer()
def test_create_user_with_token(self, connection_string):
def test_create_user_and_token(self, connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
user, token_response = identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, token_response = identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])

assert user.identifier is not None
assert token_response.token is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ async def test_create_user(self, connection_string):

@ResourceGroupPreparer(random_name_enabled=True)
@CommunicationServicePreparer()
async def test_create_user_with_token(self, connection_string):
async def test_create_user_and_token(self, connection_string):
identity_client = CommunicationIdentityClient.from_connection_string(connection_string)
async with identity_client:
user, token_response = await identity_client.create_user_with_token(scopes=[CommunicationTokenScope.CHAT])
user, token_response = await identity_client.create_user_and_token(scopes=[CommunicationTokenScope.CHAT])

assert user.identifier is not None
assert token_response.token is not None
Expand Down

0 comments on commit e0d33fc

Please sign in to comment.