Method GetRequiredSessionTokenAsync
GetRequiredSessionTokenAsync<TSessionToken>(HubCallerContext, SessionAccessOptions)
Gets the session token for the hub connection. If the user is not signed in, throws an UnauthorizedApiException (which is reported to the client as an API error when the ApiExceptionHubFilter is registered).
Declaration
public static ValueTask<TSessionToken> GetRequiredSessionTokenAsync<TSessionToken>(this HubCallerContext context, SessionAccessOptions sessionOptions = SessionAccessOptions.None) where TSessionToken : class, ISessionToken
Parameters
| Type | Name | Description |
|---|---|---|
| HubCallerContext | context | The hub caller context. |
| SessionAccessOptions | sessionOptions | Option flags for retrieving the session token. |
Returns
| Type | Description |
|---|---|
| ValueTask<TSessionToken> |
Type Parameters
| Name | Description |
|---|---|
| TSessionToken |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The hub connection does not have an HTTP context or session handling is not registered. |