OAuthPrompt Class
- java.
lang. Object - com.
microsoft. bot. dialogs. Dialog - com.
microsoft. bot. dialogs. prompts. OAuthPrompt
- com.
- com.
public class OAuthPrompt
extends Dialog
Creates a new prompt that asks the user to sign in using the Bot Frameworks Single Sign On (SSO)service. The prompt will attempt to retrieve the users current token and if the user isn't signed in, itwill send them an `OAuthCard` containing a button they can press to signin. Depending on thechannel, the user will be sent through one of two possible signin flows:- The automatic signin flow where once the user signs in and the SSO service will forward the botthe users access token using either an `event` or `invoke` activity.- The "magic code" flow where once the user signs in they will be prompted by the SSOservice to send the bot a six digit code confirming their identity. This code will be sent as astandard `message` activity. Both flows are automatically supported by the `OAuthPrompt` and the only thing you need to becareful of is that you don't block the `event` and `invoke` activities that the prompt mightbe waiting on. **Note**:You should avoid persisting the access token with your bots other state. The Bot FrameworksSSO service will securely store the token on your behalf. If you store it in your bots stateit could expire or be revoked in between turns. When calling the prompt from within a waterfall step you should use the token within the stepfollowing the prompt and then let the token go out of scope at the end of your function.
Constructor Summary
| Constructor | Description |
|---|---|
| OAuthPrompt(String dialogId, OAuthPromptSettings settings) |
Initializes a new instance of the OAuthPrompt class. |
| OAuthPrompt(String dialogId, OAuthPromptSettings settings, PromptValidator<TokenResponse> validator) |
Initializes a new instance of the OAuthPrompt class. |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
|
java.util.concurrent.CompletableFuture<Dialog |
beginDialog(DialogContext dc, Object options)
Called when a prompt dialog is pushed onto the dialog stack and is being activated. |
|
java.util.concurrent.CompletableFuture<Dialog |
continueDialog(DialogContext dc)
Called when a prompt dialog is the active dialog and the user replied with a new activity. |
|
java.util.concurrent.CompletableFuture<Token |
getUserToken(TurnContext turnContext)
Attempts to get the user's token. |
|
static
java.util.concurrent.CompletableFuture<Prompt |
recognizeToken(OAuthPromptSettings settings, DialogContext dc)
Shared implementation of the Recognize |
| static java.util.concurrent.CompletableFuture<java.lang.Void> |
sendOAuthCard(OAuthPromptSettings settings, TurnContext turnContext, Activity prompt)
Shared implementation of the Send |
| static void |
setCallerInfoInDialogState(Map<String,Object> state, TurnContext context)
Shared implementation of the Set |
| java.util.concurrent.CompletableFuture<java.lang.Void> |
signOutUser(TurnContext turnContext)
Signs out the user. |
Methods inherited from Dialog
Methods inherited from java.lang.Object
Constructor Details
OAuthPrompt
public OAuthPrompt(String dialogId, OAuthPromptSettings settings)
Initializes a new instance of the OAuthPrompt class.
Parameters:
The value of <xref uid="" data-throw-if-not-resolved="false" data-raw-source="dialogId"></xref> must be unique within the
<xref uid="com.microsoft.bot.dialogs.DialogSet" data-throw-if-not-resolved="false" data-raw-source="DialogSet"></xref> or <xref uid="com.microsoft.bot.dialogs.ComponentDialog" data-throw-if-not-resolved="false" data-raw-source="ComponentDialog"></xref> to which the
prompt is added.
OAuthPrompt
public OAuthPrompt(String dialogId, OAuthPromptSettings settings, PromptValidator
Initializes a new instance of the OAuthPrompt class.
Parameters:
The value of <xref uid="" data-throw-if-not-resolved="false" data-raw-source="dialogId"></xref> must be unique within the
<xref uid="com.microsoft.bot.dialogs.DialogSet" data-throw-if-not-resolved="false" data-raw-source="DialogSet"></xref> or <xref uid="com.microsoft.bot.dialogs.ComponentDialog" data-throw-if-not-resolved="false" data-raw-source="ComponentDialog"></xref> to which the
prompt is added.
Method Details
beginDialog
public CompletableFuture
Called when a prompt dialog is pushed onto the dialog stack and is being activated.
Overrides:
OAuthPrompt.beginDialog(DialogContext dc, Object options)Parameters:
Returns:
continueDialog
public CompletableFuture
Called when a prompt dialog is the active dialog and the user replied with a new activity.
Overrides:
OAuthPrompt.continueDialog(DialogContext dc)Parameters:
Returns:
getUserToken
public CompletableFuture
Attempts to get the user's token.
Parameters:
Returns:
If the task is successful and user already has a token or the user
successfully signs in, the result contains the user's token.
recognizeToken
public static CompletableFuture
Shared implementation of the RecognizeToken function. This is intended for internal use, to consolidate the implementation of the OAuthPrompt and OAuthInput. Application logic should use those dialog classes.
Parameters:
Returns:
sendOAuthCard
public static CompletableFuture
Shared implementation of the SendOAuthCard function. This is intended for internal use, to consolidate the implementation of the OAuthPrompt and OAuthInput. Application logic should use those dialog classes.
Parameters:
Returns:
setCallerInfoInDialogState
public static void setCallerInfoInDialogState(Map
Shared implementation of the SetCallerInfoInDialogState function. This is intended for internal use, to consolidate the implementation of the OAuthPrompt and OAuthInput. Application logic should use those dialog classes.
Parameters:
signOutUser
public CompletableFuture
Signs out the user.
Parameters:
Returns: