OAuthFlow class
Manages the OAuth flow
Constructors
OAuth |
Creates a new instance of OAuthFlow. |
Properties
abs |
The name of the OAuth connection. |
card |
The text of the OAuth card. |
card |
The title of the OAuth card. |
state | The current state of the OAuth flow. |
token |
The ID of the token exchange request, used to deduplicate requests. |
user |
The user token client used for managing user tokens. |
Methods
begin |
Begins the OAuth flow. |
continue |
Continues the OAuth flow. |
get |
Gets the user state for the OAuth flow. |
get |
Retrieves the user token from the user token service with in-memory caching for 10 minutes. |
set |
Sets the flow state for the OAuth flow. |
sign |
Signs the user out. |
Constructor Details
OAuthFlow(Storage, string, UserTokenClient, string, string)
Creates a new instance of OAuthFlow.
new OAuthFlow(storage: Storage, absOauthConnectionName: string, tokenClient: UserTokenClient, cardTitle?: string, cardText?: string)
Parameters
- storage
- Storage
The storage provider for persisting flow state.
- absOauthConnectionName
-
string
The absolute OAuth connection name.
- tokenClient
- UserTokenClient
Optional user token client. If not provided, will be initialized automatically.
- cardTitle
-
string
Optional title for the OAuth card. Defaults to 'Sign in'.
- cardText
-
string
Optional text for the OAuth card. Defaults to 'login'.
Property Details
absOauthConnectionName
The name of the OAuth connection.
absOauthConnectionName: string
Property Value
string
cardText
The text of the OAuth card.
cardText: string
Property Value
string
cardTitle
The title of the OAuth card.
cardTitle: string
Property Value
string
state
tokenExchangeId
The ID of the token exchange request, used to deduplicate requests.
tokenExchangeId: null | string
Property Value
null | string
userTokenClient
The user token client used for managing user tokens.
userTokenClient: UserTokenClient
Property Value
Method Details
beginFlow(TurnContext)
Begins the OAuth flow.
function beginFlow(context: TurnContext): Promise<undefined | TokenResponse>
Parameters
- context
- TurnContext
The turn context.
Returns
Promise<undefined | TokenResponse>
A promise that resolves to the user token if available, or undefined if OAuth flow needs to be started.
continueFlow(TurnContext)
Continues the OAuth flow.
function continueFlow(context: TurnContext): Promise<TokenResponse>
Parameters
- context
- TurnContext
The turn context.
Returns
Promise<TokenResponse>
A promise that resolves to the user token response.
getFlowState(TurnContext)
Gets the user state for the OAuth flow.
function getFlowState(context: TurnContext): Promise<FlowState>
Parameters
- context
- TurnContext
The turn context.
Returns
Promise<FlowState>
A promise that resolves to the flow state.
getUserToken(TurnContext)
Retrieves the user token from the user token service with in-memory caching for 10 minutes.
function getUserToken(context: TurnContext): Promise<TokenResponse>
Parameters
- context
- TurnContext
The turn context containing the activity information.
Returns
Promise<TokenResponse>
A promise that resolves to the user token response.
setFlowState(TurnContext, FlowState)
Sets the flow state for the OAuth flow.
function setFlowState(context: TurnContext, flowState: FlowState): Promise<void>
Parameters
- context
- TurnContext
The turn context.
- flowState
- FlowState
The flow state to set.
Returns
Promise<void>
A promise that resolves when the flow state is set.
signOut(TurnContext)
Signs the user out.
function signOut(context: TurnContext): Promise<void>
Parameters
- context
- TurnContext
The turn context.
Returns
Promise<void>
A promise that resolves when the sign-out operation is complete.