WebPubSubServiceClient Class
WebPubSubServiceClient.
- Inheritance
-
azure.messaging.webpubsubservice.aio._web_pub_sub_service_client.WebPubSubServiceClientWebPubSubServiceClient
Constructor
WebPubSubServiceClient(endpoint: str, hub: str, credential: Union[AsyncTokenCredential, AzureKeyCredential], **kwargs: Any)
Parameters
- hub
- str
Target hub name, which should start with alphabetic characters and only contain alpha-numeric characters or underscore.
- credential
- AsyncTokenCredential or AzureKeyCredential
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
- connection_string
- hub
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.
- 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
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...'
}
Feedback
Submit and view feedback for