WebPubSubServiceClient Class

WebPubSubServiceClient.

Inheritance
azure.messaging.webpubsubservice._web_pub_sub_service_client.WebPubSubServiceClient
WebPubSubServiceClient

Constructor

WebPubSubServiceClient(endpoint: str, hub: str, credential: Union[TokenCredential, 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
TokenCredential 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.

get_client_access_token

Build an authentication token.

Example:

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...'

}

from_connection_string

Create a new WebPubSubServiceClient from a connection string.

from_connection_string(connection_string: Type[ClientType], hub: str, **kwargs: str) -> ClientType

Parameters

connection_string
str
Required

Connection string

hub
str
Required

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

hub
Required

Return type

get_client_access_token

Build an authentication token.

Example:

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...'

}

get_client_access_token(**kwargs: Any) -> JSONType

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.

Returns

JSON response containing the web socket endpoint, the token and a url with the generated access token.

Return type

<xref:JSONType>