WebPubSubServiceClient Class

WebPubSubServiceClient.

Inheritance
azure.messaging.webpubsubservice.aio._web_pub_sub_service_client.WebPubSubServiceClient
WebPubSubServiceClient

Constructor

WebPubSubServiceClient(endpoint: str, hub: str, credential: Union[AsyncTokenCredential, AzureKeyCredential], **kwargs: Any)

Parameters

endpoint
str
Required

HTTP or HTTPS endpoint for the Web PubSub service instance.

hub
str
Required

Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.

credential
AsyncTokenCredential or AzureKeyCredential
Required

Credential needed for the client to connect to Azure.

api_version
str

Api Version. The default value is "2021-10-01". Note that overriding this default value may result in unsupported behavior.

Methods

from_connection_string

Create a new WebPubSubServiceClient from a connection string. :param connection_string: Connection string :type connection_string: ~str :param hub: Target hub name, which should start with alphabetic characters and only contain

alpha-numeric characters or underscore.

get_client_access_token

Generate token for the client to connect Azure Web PubSub service.

Generate token for the client to connect Azure Web PubSub service.

from_connection_string

Create a new WebPubSubServiceClient from a connection string. :param connection_string: Connection string :type connection_string: ~str :param hub: Target hub name, which should start with alphabetic characters and only contain

alpha-numeric characters or underscore.

from_connection_string(connection_string: str, hub: str, **kwargs: Any) -> azure.messaging.webpubsubservice.aio._patch.WebPubSubServiceClient

Parameters

cls
Required
connection_string
Required
hub
Required

Return type

get_client_access_token

Generate token for the client to connect Azure Web PubSub service.

Generate token for the client to connect Azure Web PubSub service.

async get_client_access_token(*, user_id: Optional[str] = None, roles: Optional[List[str]] = None, minutes_to_expire: Optional[int] = 60, jwt_headers: Dict[str, Any] = None, **kwargs: Any) -> Any

Parameters

user_id
str

User Id.

roles
list[str]

Roles that the connection with the generated token will have.

minutes_to_expire
int

The expire time of the generated token.

any] jwt_headers
dict[<xref:str,>

Any headers you want to pass to jwt encoding.

api_version
str

Api Version. The default value is "2021-10-01". Note that overriding this default value may result in unsupported behavior.

Returns

JSON object

Return type

<xref:JSONType>

Exceptions

Examples


   >>> get_client_access_token()
   {
       'baseUrl': 'wss://contoso.com/api/webpubsub/client/hubs/theHub',
       'token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ...',
       'url': 'wss://contoso.com/api/webpubsub/client/hubs/theHub?access_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ...'
   }