{"id":17948,"date":"2016-12-05T21:46:55","date_gmt":"2016-12-05T21:46:55","guid":{"rendered":"https:\/\/developer.kore.com\/?post_type=docs&#038;p=9115"},"modified":"2021-03-18T10:15:52","modified_gmt":"2021-03-18T10:15:52","slug":"setting-up-authorization-using-oauth-v2","status":"publish","type":"post","link":"https:\/\/developer.kore.ai\/v8-1\/docs\/bots\/advanced-topics\/authorization\/setting-up-authorization-using-oauth-v2\/","title":{"rendered":"Setting Up Authorization using OAuth v2"},"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>OAuth v2 is the new version of the open protocol to allow secure authorization in a simple and standard method from web, mobile, and desktop applications.<\/p>\n<p>To use oAuth v2, you must first register an account with the web application as you will need the sign in credentials for that application to configure the settings for the Authorization Mechanism.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_oAuth_v2_Works\"><span class=\"wysiwyg-font-size-large\">How oAuth v2 Works<\/span><\/span><\/h2>\n<ol>\n<li>The Kore.ai application redirects the user to a login dialog at the web application.<\/li>\n<li>The user authenticates.<\/li>\n<li>The web application\u00a0redirects the user back to the Kore.ai application with an access token.<\/li>\n<li>The Kore.ai application validates the\u00a0access token.<\/li>\n<li>The access token allows the Kore.ai application\u00a0to access a protected resource at the provider, on behalf of the user.<\/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=\"Defining_oAuth_v2\">Defining oAuth v2<\/span><\/h2>\n<p>To define Authorization for your bot, follow these steps:<\/p>\n<ol>\n<li>Open the bot for which you want to configure an Authorization profile.<\/li>\n<li>Hover over the left-side navigation panel and from <strong>Settings -&gt; Config Settings<\/strong> select <strong>Authorization Profile<\/strong><br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/18\/auth-profiles.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-21924\" src=\"\/wp-content\/uploads\/sites\/18\/auth-profiles.png\" alt=\"\" width=\"349\" height=\"569\" srcset=\"https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/18\/20221201101820\/auth-profiles.png 349w, https:\/\/kore-wordpress.s3.us-east-2.amazonaws.com\/developer.kore.ai\/wp-content\/uploads\/sites\/18\/20221201101820\/auth-profiles-184x300.png 184w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/a><\/li>\n<li>Click<strong> Add<\/strong>.\u00a0The <strong>New Authorization Mechanism<\/strong> dialog opens.<\/li>\n<li>In the <strong>Authorization Type<\/strong>\u00a0drop-down list, select\u00a0<strong>auth v2<\/strong>.<\/li>\n<li>In the\u00a0<strong>Name<\/strong>\u00a0field, enter the name for your authorization.<\/li>\n<\/ol>\n<p>The following illustration is an example of the <strong>oAuth v2<\/strong>\u00a0fields that you must define to enable basic authorization for your Bot.<br \/>\n<a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/18\/First-screen-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14729 alignnone\" src=\"\/wp-content\/uploads\/sites\/18\/First-screen-1.png\" alt=\"\" width=\"402\" height=\"436\" \/><\/a><\/p>\n<p>To configure oAuth v2, define the fields described in the following table.<\/p>\n<table width=\"100%\">\n<thead>\n<tr>\n<th class=\"wysiwyg-text-align-left\">FIELD NAME<\/th>\n<th class=\"wysiwyg-text-align-left\">DESCRIPTION<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Authorization Type<\/td>\n<td>Set to oAuth v2.<\/td>\n<\/tr>\n<tr>\n<td>Bots\u00a0Callback Link<\/td>\n<td>The URL used by the web application or web service to redirect the end-user after end-user authorization is complete. This value, <span style=\"color: #0000ff\">https:\/\/idp.kore.ai\/workflows\/callback\/<\/span>\u00a0is provided as a read-only value by the Kore.ai application when you define oAuth v2 settings.<\/td>\n<\/tr>\n<tr>\n<td>Identity Provider Name<\/td>\n<td>The name of the web application or web service, for example, <em>Asana<\/em>. This field is required.<\/td>\n<\/tr>\n<tr>\n<td>Client ID<\/td>\n<td>The ID of the Kore.ai client.<\/td>\n<\/tr>\n<tr>\n<td>Client Secret Key<\/td>\n<td>The value provided as the Kore.ai application authentication based on the Client ID\u00a0to the web application.<\/td>\n<\/tr>\n<tr>\n<td>Authorization\u00a0URL<\/td>\n<td>This is the URL used to obtain end-user\u00a0authorization for the Kore.ai application to access the web application or web service using the access token.\u00a0This field is required. You can use dynamic fields, path parameter fields, query fields, and so forth, to define the Authorization\u00a0URL, for example,<br \/>\n<span style=\"color: #0000ff\">\u00a0 \u00a0 \u00a0https:\/\/kore.someCompany.com\/sap\/opu\/odata\/sap\/{{authfield1}}\/?$format=json<br \/>\n<\/span>or<br \/>\n<span style=\"color: #0000ff\">\u00a0 \u00a0 \u00a0https:\/\/{tenant}.service-now.com\/api\/now\/v1\/table\/incident<\/span><br \/>\nFor more information, see <a href=\"\/v8-1\/docs\/bots\/bot-builder\/defining-bot-tasks\/using-session-and-context-variables-in-tasks\/\">Using Session and Context Variables in Tasks<\/a>.<\/td>\n<\/tr>\n<tr>\n<td>Access Using a Connector<\/td>\n<td>Select <strong>Yes<\/strong> to enable access for Kore.ai Bots using the Kore.ai Connector agent. This option is only visible if a Kore.ai Connector agent is configured and enabled in your enterprise on-premises network. For more information, see <a href=\"\/v8-1\/docs\/bots\/admin-console\/security-control\/security-module-overview\/#Why_Use_the_Koreai_Connector_for_Bots\">Using the Kore.ai Connector<\/a>.<\/td>\n<\/tr>\n<tr>\n<td>Token Request URL<\/td>\n<td>The URL used by the Kore.ai application to obtain an unauthorized request token. A request token is a value used by the Kore.ai application to obtain authorization from the end-user to obtain an access token. After end-user authorization, an access token can be requested by the Kore.ai application. This field is required.<\/td>\n<\/tr>\n<tr>\n<td>Scope<\/td>\n<td>If the Bot web service requires additional values for authorization, add one or more <span style=\"color: #0000ff\">Key\/Value<\/span> pairs. For example, some Bot web services support using a <span style=\"color: #0000ff\">scope<\/span> key using\u00a0<span style=\"color: #0000ff\">read-only<\/span>, <span style=\"color: #0000ff\">write<\/span>, or\u00a0<span style=\"color: #0000ff\">both<\/span> as the value.<\/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<h3><span class=\"ez-toc-section\" id=\"Defining_Tenancy\">Defining Tenancy<\/span><\/h3>\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 that 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 at <span style=\"color: #0000ff\">www.<strong><em>kore<\/em><\/strong>.someCompany.com.<\/span><\/p>\n<p>In 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\/18\/Tenancy-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14725\" src=\"\/wp-content\/uploads\/sites\/18\/Tenancy-1.png\" alt=\"\" width=\"557\" height=\"162\" \/><\/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<h3><span class=\"ez-toc-section\" id=\"Adding_Additional_Fields\">Adding Additional Fields<\/span><\/h3>\n<p>Click <strong>Add<\/strong> to open the <strong>Additional Fields<\/strong> dialog and then enter one or more key\/value pairs that represent additional authorization input fields.<\/p>\n<p>If the default username and password fields do not meet your needs for authorization input, you can add custom fields as key\/value pairs that are displayed to the end-user by adding <strong>Additional Fields<\/strong>. You can use these fields, for example, if a PIN code is required in the authorization process, in addition to the <strong>Username<\/strong> and <strong>Password<\/strong> fields.<\/p>\n<p><strong>Additional Fields<\/strong> are added as shown in the following illustration.<\/p>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/18\/Additional-Fields-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14726 alignnone\" src=\"\/wp-content\/uploads\/sites\/18\/Additional-Fields-1.png\" alt=\"\" width=\"602\" height=\"154\" \/><\/a><br \/>\nSpecify the following fields:<\/p>\n<ul>\n<li><strong>Field Key<\/strong> &#8211; The\u00a0name of the custom field to specify\u00a0for authorization.<\/li>\n<li><strong>Value<\/strong> &#8211; The value of the custom field to specify for the authorization.<\/li>\n<\/ul>\n<p>Click <strong>Add<\/strong> to save the <strong>Additional Field<\/strong>.<br \/>\nTo add more <strong>Additional Fields<\/strong>, click <strong>Add<\/strong>\u00a0in the <strong>Additional Fields<\/strong> section.<\/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<h3><span class=\"ez-toc-section\" id=\"Adding_Authorization_Fields\"><span class=\"wysiwyg-font-size-large\">Adding Authorization Fields<\/span><\/span><\/h3>\n<p>By default, no authorization fields are configured as part of the header of the Bot\u00a0request message. If your Bot\u00a0request requires authorization fields or the expected authorization is not part of the header, for example, social security number or PIN, click <strong>Add<\/strong>\u00a0in the <strong>Authorization Fields<\/strong> section and then define the fields as shown in the following illustration.<\/p>\n<p><a ref=\"magnificPopup\" href=\"\/wp-content\/uploads\/sites\/18\/Authorization-field-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-14728 alignnone\" src=\"\/wp-content\/uploads\/sites\/18\/Authorization-field-1.png\" alt=\"\" width=\"527\" height=\"214\" \/><\/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 Bot\u00a0request message and the type of authorization fields that are required.\n<ul>\n<li><strong>Header<\/strong> &#8211;\u00a0The Bot\u00a0expects the authorization fields as part of the header\u00a0of the request.<\/li>\n<li><strong>Payload<\/strong> &#8211; The Bot\u00a0expects the authorization fields as part of the content of the body of the request.<\/li>\n<li><strong>Query String<\/strong> &#8211;\u00a0The Bot\u00a0expects the authorization fields as a query in the body\u00a0of the request.<\/li>\n<li><strong>Path Param<\/strong> &#8211; The Bot expects the authorization fields as part of the URL path for the request.<\/li>\n<\/ul>\n<\/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 <strong>Add<\/strong>. The new authorization field is added in the <strong>Authorization Fields<\/strong> section.<\/li>\n<\/ol>\n<p>To add additional authorization fields, click <strong>Add<\/strong>\u00a0in the <strong>Authorization\u00a0Fields<\/strong> section.<\/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<h3><span class=\"ez-toc-section\" id=\"Testing_the_Authorization\"><span style=\"color: inherit\">Testing the Authorization<\/span><\/span><\/h3>\n<p>After you save the authentication,\u00a0you can test your authorization definition on the <strong>Authentication<\/strong> page when you click <strong>Test <\/strong>before continuing to develop the remain steps of your task. When you\u00a0click <strong>Test<\/strong>, the test is executed using the authentication token URLs and the <strong>Client ID<\/strong>\u00a0and <strong>Client Secret Key<\/strong>. If tenancy was defined, the <strong>Test Authorization<\/strong> dialog is displayed.<\/p>\n<p>Click <strong>Test<\/strong>\u00a0to begin the authorization test.\u00a0When the validation of authentication is complete, the <strong>Test Authorization<\/strong> dialog 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\/18\/DIYTestAuthorizationDialogFail.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8684 alignnone\" src=\"\/wp-content\/uploads\/sites\/18\/DIYTestAuthorizationDialogFail.png\" alt=\"Test Authorization Failure Dialog\" width=\"595\" height=\"473\" \/><\/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><\/div><\/div><\/div><\/div><\/div><\/section>\n","protected":false},"excerpt":{"rendered":"OAuth v2 is the new version of the open protocol to allow secure authorization in a simple and standard method from web, mobile, and desktop applications. To use oAuth v2, you must first register an account with the web application as you will need the sign in credentials for that application to configure the settings...","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-17948","post","type-post","status-publish","format-standard","hentry","category-authorization"],"_links":{"self":[{"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/posts\/17948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/comments?post=17948"}],"version-history":[{"count":6,"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/posts\/17948\/revisions"}],"predecessor-version":[{"id":24493,"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/posts\/17948\/revisions\/24493"}],"wp:attachment":[{"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/media?parent=17948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/categories?post=17948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developer.kore.ai\/v8-1\/wp-json\/wp\/v2\/tags?post=17948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}