{"id":27040,"date":"2021-03-17T05:52:27","date_gmt":"2021-03-17T05:52:27","guid":{"rendered":"https:\/\/developer.kore.ai\/v9-1\/?p=27040"},"modified":"2021-03-17T05:52:27","modified_gmt":"2021-03-17T05:52:27","slug":"alert-task-oauth-v2-password-grant-type","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v9-1\/docs\/bots\/bot-builder-tool\/alert\/alert-task-oauth-v2-password-grant-type\/","title":{"rendered":"Alert Task \u2013 OAuth v2 Password Grant Type"},"content":{"rendered":"<section class=\"l-section wpb_row height_auto\"><div class=\"l-section-h i-cf\"><div class=\"g-cols vc_row type_default valign_top\"><div class=\"vc_col-sm-12 wpb_column vc_column_container\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<p>We have seen how an Alert task can be set up in Kore.ai virtual assistant platform <a href=\"\/docs\/bots\/bot-builder-tool\/alert\/notification-tasks\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>. In this section, we will see how authorization for the alert tasks can be set up using the OAuth v2 with password grant.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Setting_Up\">Setting Up<\/span><\/h2>\n<p>The following illustration is an example of the <strong>oAuth v2 password grant<\/strong>\u00a0authorization type fields that you must define to enable a customized authorization for your task.<\/p>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYoAuthv2PasswordDialog.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8671\" src=\"\/wp-content\/uploads\/sites\/22\/DIYoAuthv2PasswordDialog.png\" alt=\"New Authorization Mechanism Dialog - oAuth v2 password grant\" width=\"449\" height=\"967\" \/><\/a><\/p>\n<p>To define a custom authorization, select <strong>oAuth v2 password grant<\/strong>\u00a0in the <strong>Authorization Type<\/strong> field.\u00a0Then specify a\u00a0<strong>Name<\/strong>\u00a0for the authorization to be displayed in the Bot\u00a0builder user interface.<\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Define_Tenancy\">Define Tenancy<\/span><\/h2>\n<p>If\u00a0required, in the\u00a0<strong>Subdomain<\/strong>\u00a0section, select <strong>Yes<\/strong>\u00a0if the base URL for a web application or user interface the uses a\u00a0tenant name in the URL. For example,\u00a0<span style=\"color: #0000ff;\">kore<\/span> is the tenant organization for a web service using tenants as <span style=\"color: #0000ff;\">www.<strong><em>kore<\/em><\/strong>.someCompany.com.<\/span><br \/>\nIn the following example configuration, the tenancy URL contains the <span style=\"color: #0000ff;\">{tenant}<\/span> organization placeholder.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYTaskSubdomain-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16881\" src=\"\/wp-content\/uploads\/sites\/22\/DIYTaskSubdomain-1.png\" alt=\"\" width=\"650\" height=\"189\" \/><\/a><\/p>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Form_Fields\"><span class=\"wysiwyg-font-size-large\">Form Fields<\/span><\/span><\/h2>\n<p>If the default username and password fields do not meet your needs, you can add new\u00a0fields displayed to the end-user by adding authorization form fields. To add fields\u00a0on the authorization form,<\/p>\n<ul>\n<li>Click <strong>+\u00a0Add\u00a0Form Field<\/strong>.<\/li>\n<\/ul>\n<p>The following\u00a0illustration is an example of a definition to add a password field\u00a0to the authorization dialog.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYBasicAuthDialogAddIDP-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16884\" src=\"\/wp-content\/uploads\/sites\/22\/DIYBasicAuthDialogAddIDP-1.png\" alt=\"\" width=\"650\" height=\"711\" \/><\/a><br \/>\nThe following table describes the fields used to define an authorization IDP form field.<\/p>\n<table>\n<thead>\n<tr>\n<th class=\"wysiwyg-text-align-left\" scope=\"col\">FIELD NAME<\/th>\n<th class=\"wysiwyg-text-align-left\">DESCRIPTION<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Field Title<\/td>\n<td>Specify the name of the field\u00a0displayed to the end-user in the authentication dialog.<\/td>\n<\/tr>\n<tr>\n<td>Field Key<\/td>\n<td>The value represents the end-user input value to the authenticating service.<\/td>\n<\/tr>\n<tr>\n<td>Help Hint<\/td>\n<td>The help text displayed in the field to describe what should be entered into the field.<\/td>\n<\/tr>\n<tr>\n<td>Field Type<\/td>\n<td>When <strong>Advanced Options<\/strong> is selected, specify the type of field displayed in the end-user interface to collect the user input assigned as the value for the <strong>Field Key<\/strong>, one of:<\/p>\n<ul>\n<li><strong>Textbox<\/strong><\/li>\n<li><strong>Password<\/strong><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td>Mandatory<\/td>\n<td>When <strong>Advanced Options<\/strong> is selected, select if the end-user must define this field to complete authentication.<\/td>\n<\/tr>\n<tr>\n<td>Data Type<\/td>\n<td>When <strong>Advanced Options<\/strong> is selected, specify the type of data expected as input from the end-user, for example, <strong>String<\/strong>.<\/td>\n<\/tr>\n<tr>\n<td>Visibility<\/td>\n<td>When <strong>Advanced Options<\/strong> is selected, specify if the authentication field should be visible, hidden, or displayed as read-only.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Authorization_Fields\"><span class=\"wysiwyg-font-size-large\">Authorization Fields<\/span><\/span><\/h2>\n<p>By default, authorization fields are configured as part of the header of the task\u00a0request message. If your task\u00a0request requires additional authorization fields or the expected authorization is not part of the header, for example, social security number or PIN, click<strong> + Add\u00a0Authorization Field\u00a0<\/strong>and then define the fields as shown in the following illustration.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicAuthField-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16883\" src=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicAuthField-1.png\" alt=\"\" width=\"650\" height=\"272\" \/><\/a><\/p>\n<ol>\n<li>In the <strong>Field Type<\/strong> field, you can select one of the following depending on where in the task request message and the type of authorization fields that are required.<br \/>\n<strong>Header<\/strong> &#8211;\u00a0The Bot\u00a0expects the authorization fields as part of the header\u00a0of the request.<strong>Payload<\/strong> &#8211; The Bot\u00a0expects the authorization fields as part of the content of the body of the request.<strong>Query String<\/strong> &#8211;\u00a0The Bot\u00a0expects the authorization fields as a query in the body\u00a0of the request.<strong>Path Param<\/strong> &#8211; The Bot expects the authorization fields as part of the URL path for the request.<\/li>\n<li>In the <strong>Field Key<\/strong> field, enter the name of the field for the selected <strong>Field Type<\/strong>.<\/li>\n<li>In the <strong>Field Value<\/strong> field,\u00a0enter the value for the <strong>Field Key<\/strong> specified.<\/li>\n<li>Click <b>Done<\/b>. The new authorization field is added in the <strong>Authorization Fields<\/strong> section.<\/li>\n<li>To add additional authorization fields, click <strong>Add<\/strong>\u00a0in the <strong>Authorization\u00a0Fields<\/strong> section.<\/li>\n<\/ol>\n<h5>Define the Token URL<\/h5>\n<p>To define the token URL, follow the below steps:<\/p>\n<ol>\n<li>In the <strong>Token\u00a0URL<\/strong> field, optionally define a URL that can be used to test the authentication settings from Bot\u00a0Builder before you deploy the task\u00a0with the authorization mechanism. You can use dynamic fields, path parameter fields, query fields, and so forth, to define the test URL, for example,<br \/>\n<span style=\"color: #0000ff;\">http:\/\/{tenant}.someCompany.com\/test\/{{tokenId}}<\/span><\/li>\n<li>In the <strong>Token URL Method<\/strong> field, select the HTTP request method type for the <strong>Token URL<\/strong>. One of <strong>PUT<\/strong>, <strong>POST<\/strong>, <strong>PATCH<\/strong>, <strong>DELETE,<\/strong>\u00a0and <strong>GET<\/strong>.<\/li>\n<li>In the <strong>Token URL Content Type<\/strong> field,\u00a0select the content type expected from the <strong>Token\u00a0URL<\/strong>. One of: <strong>JSON, RSS, XML, URL Encoded JSON, CSV, Text, Twitter Encoded JSON, Multipart\/Form-data,Multipart\/Related<\/strong>, or <strong>Oracle ADF<\/strong>.<\/li>\n<li>In the <strong>Access Using a Connector<\/strong> section, select <strong>Yes<\/strong> to enable access for Kore.ai Bots using the Kore.ai Connector agent. If your domain does not have any active Kore.ai Connectors defined, a warning message is displayed to contact the Bots Admin Console system administrator. For more information, refer to <a href=\"\/docs\/bots\/admin-console\/security-control\/security-module-overview\/#Why_Use_the_Koreai_Connector_for_Bots\">Using the Kore.ai Connector<\/a> in the Bots Admin Console documentation.<\/li>\n<li>Click <strong>Save Auth<\/strong>\u00a0to save the authorization settings and close the <strong>New Authorization Mechanism<\/strong> dialog.<\/li>\n<\/ol>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div>\r\n\t<div class=\"wpb_text_column \">\r\n\t\t<div class=\"wpb_wrapper\">\r\n\t\t\t<h2><span class=\"ez-toc-section\" id=\"Testing\"><span class=\"wysiwyg-font-size-large\">Testing<\/span><\/span><\/h2>\n<p>To test your authorization, follow the below steps:<\/p>\n<ol>\n<li>After you save the authentication, if you have defined an <strong>Authorization URL<\/strong> for your new authorization type, you can test your authorization definition on the <strong>Authorization <\/strong>page when you click <strong>Test Authorization<\/strong> before continuing to develop the remain steps of your task.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicTestAuth-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9864\" src=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicTestAuth-1.png\" alt=\"Test Authorization\" width=\"976\" height=\"187\" \/><\/a><\/li>\n<li>After you click <strong>Test Authorization<\/strong>, the <strong>Test Authorization<\/strong> window is displayed and populated with the URL you specified in the <strong>Authorization Check URL<\/strong> section, as shown in the following illustration.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicTestAuthOAuthV2PassTest.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9862\" src=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicTestAuthOAuthV2PassTest.png\" alt=\"Test Authorization Dialog - OAuth V2 Password Grant\" width=\"590\" height=\"620\" \/><\/a><\/li>\n<li>Click <strong>Test<\/strong> to begin the authorization test. When the validation of authentication is complete, the <strong>Test Authorization<\/strong> window is closed and the results of the validation, either success or failure, is displayed to the immediate right of the <strong>Test Authorization<\/strong> button. If the authorization fails, the <em>Auth Test Failed<\/em> message is displayed along with the <strong>Headers<\/strong> and <strong>Response<\/strong> tabs as shown in the following illustration.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicTestTestFail.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9858\" src=\"\/wp-content\/uploads\/sites\/22\/DIYActionTaskAPIRequestTabAuthenticationSectionBasicTestTestFail.png\" alt=\"Authentication Test Fail\" width=\"578\" height=\"409\" \/><\/a><\/li>\n<\/ol>\n\r\n\t\t<\/div>\r\n\t<\/div>\r\n<div class=\"w-separator size_small with_line width_default thick_1 style_solid color_border align_center\"><div class=\"w-separator-h\"><\/div><\/div><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"We have seen how an Alert task can be set up in Kore.ai virtual assistant platform here. In this section, we will see how authorization for the alert tasks can be set up using the OAuth v2 with password grant. Setting Up The following illustration is an example of the oAuth v2 password grant\u00a0authorization type...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[67],"tags":[],"class_list":["post-27040","post","type-post","status-publish","format-standard","hentry","category-alert"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/27040","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/comments?post=27040"}],"version-history":[{"count":1,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/27040\/revisions"}],"predecessor-version":[{"id":27041,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/posts\/27040\/revisions\/27041"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/media?parent=27040"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/categories?post=27040"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v9-1\/wp-json\/wp\/v2\/tags?post=27040"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}