<h2>OAuth - Authorization Code Grant flow requires User Interventions from the UI and cannot be automated programmatically</h2><br/><div style="overflow-x:auto"><article><div ><h3 >Issue </h3><section><ul style="list-style-position: inside;"><li>Considering the scenario where: <ol style="list-style-position: inside; list-style-type: lower-alpha;"><li>An external application is the <strong>3rd Party OAuth Provider</strong></li><li>The instance has defined a third party OAuth Provider record</li><li>The OAuth Provider record has the <strong>Default Grant type set to Authorization Code</strong></li><li>A <strong>REST Message</strong> is defined with Authentication type to OAuth 2.0 and the OAuth profile defined at b.</li></ol> </li><li>Clicking the <span style="color: #ff0000;"><strong>Get OAuth Token</strong></span> UI Action in the REST Message at point d. will request an authorization token from the 3rd Party OAuth Provider. This will open a <em>Request for Permission</em> window to the user UI (Browser).</li><li>This <strong><em>Request for Permission step cannot be automated programmatically</em></strong>.</li></ul></section></div><div ><h3 >Release</h3><section><ul style="list-style-position: inside;"><li>Any release</li></ul></section></div><div ><h3 >Cause</h3><section><ul style="list-style-position: inside;"><li>This is <strong>expected behavior</strong>. The <strong>User Permission must be</strong> provided with an <strong>interactive</strong> User Intervention, this is on purpose.</li><li>However, once the access and refresh tokens are retrieved in the above step, the refresh token will be used automatically by ServiceNow until its expiration to get new access tokens as and when required.</li></ul></section></div><div ><h3 >Resolution</h3><section><ul style="list-style-position: inside;"><li>If the requirement is to have a <strong>non-interactive</strong> integration with OAuth provided authorization the possible approaches (if supported by the 3rd Party Application Endpoint) are: <ul style="list-style-position: inside;"><li><strong>Client Credentials Grant Type</strong></li><li><strong>JWT grant type</strong></li></ul> </li></ul></section></div><div ><h3 >Related Links</h3><section><ul style="list-style-position: inside;"><li>Please review the following documentation for your further information:</li><li><a title="OAuth 2.0 Authorization Code Grant flow" href="https://docs.servicenow.com/csh?topicname=c_OAuthAuthorizationCodeFlow.html&version=latest" target="_blank" rel="noopener noreferrer nofollow">OAuth 2.0 Authorization Code Grant flow</a></li><li><a title="OAuth 3rd Party Provider - Authorization Code Grant Flow - Example" href="https://docs.servicenow.com/csh?topicname=c_OAuth2ProfileTutorialGoogle.html&version=latest" target="_blank" rel="noopener noreferrer nofollow">OAuth 3rd Party Provider - Authorization Code Grant Flow - Example</a></li><li><a title="What is the Authorization Code Grant Flow" href="https://developer.okta.com/blog/2018/04/10/oauth-authorization-code-grant-type" target="_blank" rel="noopener noreferrer nofollow">What is the Authorization Code Grant Flow</a></li><li><a title="OAuth 2.0 Client Credentials" href="https://docs.servicenow.com/csh?topicname=c_OAuthApplications.html&version=latest" target="_blank" rel="noopener noreferrer nofollow">OAuth 2.0 Client Credentials</a></li><li><a title="OAuth 2.0 JWT Bearer grant type" href="https://docs.servicenow.com/csh?topicname=JWT-Bearer-token-support.html&version=latest" target="_blank" rel="noopener noreferrer nofollow">OAuth 2.0 JWT Bearer grant type</a></li></ul></section></div></article></div>