<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Token-based oAuth2 call using authorization code flow (via the SAP OAuth 2.0 client) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529734#M2005350</link>
    <description>&lt;P&gt;See SAP note 3041322 - OAuth 2.0 Client: Downport of grant type Client Credentials&lt;/P&gt;</description>
    <pubDate>Thu, 20 Jan 2022 08:48:57 GMT</pubDate>
    <dc:creator>larshp</dc:creator>
    <dc:date>2022-01-20T08:48:57Z</dc:date>
    <item>
      <title>Token-based oAuth2 call using authorization code flow (via the SAP OAuth 2.0 client)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529733#M2005349</link>
      <description>&lt;P&gt;Dear SAP community,&lt;/P&gt;
  &lt;P&gt;a viewer (web application) is to be called up on our SAP system using a toolbar button. This call should be token-based via oAuth2 using an authorization code flow of the oAuth 2.0 client:&lt;/P&gt;
  &lt;P&gt;&lt;A href="https://help.sap.com/viewer/e815bb97839a4d83be6c4fca48ee5777/7.5.6/en-US/3041aa0be8194960ad02fb6f07d04dba.html"&gt;https://help.sap.com/viewer/e815bb97839a4d83be6c4fca48ee5777/7.5.6/en-US/3041aa0be8194960ad02fb6f07d04dba.html&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;The associated oAuth2 nodes in the SICF are activated, an OAuth2.0. Client profile created via the SE80, an OAuth2.0. Client created via transaction OA2C_CONFIG, I have the necessary authorizations, the certificates were stored using STRUSTSSO2, the button in the toolbar of the ALV in the SAP system has been added, but I am currently stuck with the implementation. There are several blog entries that I have already worked through:&lt;/P&gt;
  &lt;P&gt;· &lt;A href="https://blogs.sap.com/2020/12/18/configuring-oauth-2.0-and-creating-an-abap-program-that-uses-oauth-2.0-client-api/"&gt;Configuring OAuth 2.0 and Creating an ABAP Program That Uses OAuth 2.0 Client API&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;· &lt;A href="https://laptrinhx.com/news/how-to-set-up-an-oauth-2-0-client-profile-in-as-abap-E3Qve6G/"&gt;How to Set up an OAuth 2.0 Client Profile in AS ABAP?&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt;An instance of the OAuth 2.0 client is created there via cl_oauth2_client=&amp;gt;create(). Then a token is fetched using lo_oa2c_client-&amp;gt;execute_cc_flow (Client Credential Flow) and transferred to the http client.&lt;/P&gt;
  &lt;P&gt;But my problem is that I would like to start an authorization code flow and the class CL_OAUTH2_CLIENT only offers the possibility to start a SAML 2.0 flow (lo_oa2c_client-&amp;gt;execute_saml20_flow) or an update flow (lo_oa2c_client-&amp;gt; execute_refresh_flow). Our SAP_BASIS module has version 7.50 SP22.&lt;/P&gt;
  &lt;P&gt;Is it true, that there are exactly two ways to authorize the AS ABAP to access the end user's resources by requesting an OAuth 2.0 access token for your service provider:&lt;/P&gt;
  &lt;P&gt;1. call the grant endpoint with the suitable URL (https://&amp;lt;Hostname&amp;gt;:&amp;lt;Portnumber&amp;gt;/sap/bc/sec/oauth2/client/grant/authorization?profile= ZMY_CLIENT_PROFILE) or&lt;/P&gt;
  &lt;P&gt;2. use the transaction OA2C_GRANT?&lt;/P&gt;
  &lt;P&gt;As described here: &lt;A href="https://help.sap.com/viewer/3c4e8fc004cb4401a4fdd737f02ac2b9/7.5.6/en-US/0b5cbbddd1e741f39dcb7dcc0ef13c51.html"&gt;Requesting an OAuth 2.0 Access Token&lt;/A&gt;&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;So for me there is still the question of how I can call the grant endpoint from my ABAP program - is this a simple HTTP GET request and does anybody know how to do this?&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt; &lt;/P&gt;
  &lt;P&gt;The implementation should be similar to the REPORT zhelloworld in this blog article &lt;A href="https://wiki.scn.sap.com/wiki/plugins/servlet/mobile?contentId=392069576#content/view/390989482"&gt;Access SAP Hana Cloud Platform using the OAuth 2.0 Client API&lt;/A&gt; by Joachim Doersam:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&lt;STRONG&gt;REPORT &lt;/STRONG&gt;zhelloworld &lt;STRONG&gt;LINE-SIZE &lt;/STRONG&gt;1023.&lt;BR /&gt;
&lt;BR /&gt;
&lt;STRONG&gt;DATA&lt;/STRONG&gt;: profile         &lt;STRONG&gt;TYPE &lt;/STRONG&gt;oa2c_profile,&lt;BR /&gt;
      target          &lt;STRONG&gt;TYPE &lt;/STRONG&gt;string,&lt;BR /&gt;
      &lt;STRONG&gt;method          TYPE &lt;/STRONG&gt;string,&lt;BR /&gt;
      lo_http_client  &lt;STRONG&gt;TYPE REF TO &lt;/STRONG&gt;if_http_client,&lt;BR /&gt;
      lo_oa2c_client  &lt;STRONG&gt;TYPE REF TO &lt;/STRONG&gt;if_oauth2_client,&lt;BR /&gt;
      l_status_code   &lt;STRONG&gt;TYPE i&lt;/STRONG&gt;,&lt;BR /&gt;
      l_response_data &lt;STRONG&gt;TYPE &lt;/STRONG&gt;string,&lt;BR /&gt;
      lt_fields       &lt;STRONG&gt;TYPE &lt;/STRONG&gt;tihttpnvp,&lt;BR /&gt;
      lx_oa2c         &lt;STRONG&gt;TYPE REF TO &lt;/STRONG&gt;cx_oa2c.&lt;BR /&gt;
&lt;BR /&gt;
&lt;STRONG&gt;FIELD-SYMBOLS&lt;/STRONG&gt;: &amp;lt;ls_field&amp;gt; &lt;STRONG&gt;LIKE LINE OF &lt;/STRONG&gt;lt_fields.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;STRONG&gt;START-OF-SELECTION&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
  profile = 'ZMY_CLIENT_PROFILE'.&lt;BR /&gt;
  target  = 'https://helloworld&amp;lt;YourAccount&amp;gt;.hanatrial.ondemand.com/HelloWorld/'.&lt;BR /&gt;
  &lt;STRONG&gt;method  &lt;/STRONG&gt;= 'GET'.&lt;BR /&gt;
&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;* Create HTTP client&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
  &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;cl_http_client&lt;STRONG&gt;=&amp;gt;&lt;/STRONG&gt;create_by_url&lt;BR /&gt;
    &lt;STRONG&gt;EXPORTING&lt;/STRONG&gt;&lt;BR /&gt;
      url                = target&lt;BR /&gt;
      ssl_id             = 'ANONYM'&lt;BR /&gt;
    &lt;STRONG&gt;IMPORTING&lt;/STRONG&gt;&lt;BR /&gt;
      &lt;STRONG&gt;client             &lt;/STRONG&gt;= lo_http_client&lt;BR /&gt;
    &lt;STRONG&gt;EXCEPTIONS&lt;/STRONG&gt;&lt;BR /&gt;
      argument_not_found = 1&lt;BR /&gt;
      plugin_not_active  = 2&lt;BR /&gt;
      internal_error     = 3&lt;BR /&gt;
      &lt;STRONG&gt;OTHERS             &lt;/STRONG&gt;= 4.&lt;BR /&gt;
  &lt;STRONG&gt;IF &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;
    &lt;STRONG&gt;MESSAGE ID &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgid &lt;STRONG&gt;TYPE &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgty &lt;STRONG&gt;NUMBER &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgno&lt;BR /&gt;
               &lt;STRONG&gt;WITH &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv1 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv2 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv3 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv4.&lt;BR /&gt;
  &lt;STRONG&gt;ENDIF&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
  lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;propertytype_logon_popup = 0.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;request&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;set_method&lt;BR /&gt;
    &lt;STRONG&gt;EXPORTING&lt;/STRONG&gt;&lt;BR /&gt;
      &lt;STRONG&gt;method &lt;/STRONG&gt;= &lt;STRONG&gt;method&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;* Set OAuth 2.0 Token&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
  &lt;STRONG&gt;TRY&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
      &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;cl_oauth2_client&lt;STRONG&gt;=&amp;gt;create&lt;/STRONG&gt;&lt;BR /&gt;
        &lt;STRONG&gt;EXPORTING&lt;/STRONG&gt;&lt;BR /&gt;
          i_profile        = profile&lt;BR /&gt;
        RECEIVING&lt;BR /&gt;
          ro_oauth2_client = lo_oa2c_client.&lt;BR /&gt;
&lt;BR /&gt;
    &lt;STRONG&gt;CATCH &lt;/STRONG&gt;cx_oa2c &lt;STRONG&gt;INTO &lt;/STRONG&gt;lx_oa2c.&lt;BR /&gt;
      &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: 'Error calling CREATE.'.&lt;BR /&gt;
      &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: / lx_oa2c&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_text( ).&lt;BR /&gt;
      &lt;STRONG&gt;RETURN&lt;/STRONG&gt;.&lt;BR /&gt;
  &lt;STRONG&gt;ENDTRY&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;STRONG&gt;TRY&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
      &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_oa2c_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;set_token&lt;BR /&gt;
        &lt;STRONG&gt;EXPORTING&lt;/STRONG&gt;&lt;BR /&gt;
          io_http_client = lo_http_client.&lt;BR /&gt;
&lt;BR /&gt;
    &lt;STRONG&gt;CATCH &lt;/STRONG&gt;cx_oa2c &lt;STRONG&gt;INTO &lt;/STRONG&gt;lx_oa2c.&lt;BR /&gt;
      &lt;STRONG&gt;TRY&lt;/STRONG&gt;.&lt;BR /&gt;
          &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_oa2c_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;execute_refresh_flow.&lt;BR /&gt;
        &lt;STRONG&gt;CATCH &lt;/STRONG&gt;cx_oa2c &lt;STRONG&gt;INTO &lt;/STRONG&gt;lx_oa2c.&lt;BR /&gt;
          &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: 'Error calling EXECUTE_REFRESH_FLOW.'.&lt;BR /&gt;
          &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: / lx_oa2c&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_text( ).&lt;BR /&gt;
          &lt;STRONG&gt;RETURN&lt;/STRONG&gt;.&lt;BR /&gt;
      &lt;STRONG&gt;ENDTRY&lt;/STRONG&gt;.&lt;BR /&gt;
      &lt;STRONG&gt;TRY&lt;/STRONG&gt;.&lt;BR /&gt;
          &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_oa2c_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;set_token&lt;BR /&gt;
            &lt;STRONG&gt;EXPORTING&lt;/STRONG&gt;&lt;BR /&gt;
              io_http_client = lo_http_client.&lt;BR /&gt;
        &lt;STRONG&gt;CATCH &lt;/STRONG&gt;cx_oa2c &lt;STRONG&gt;INTO &lt;/STRONG&gt;lx_oa2c.&lt;BR /&gt;
          &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: 'Error calling SET_TOKEN.'.&lt;BR /&gt;
          &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: / lx_oa2c&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_text( ).&lt;BR /&gt;
          &lt;STRONG&gt;RETURN&lt;/STRONG&gt;.&lt;BR /&gt;
      &lt;STRONG&gt;ENDTRY&lt;/STRONG&gt;.&lt;BR /&gt;
  &lt;STRONG&gt;ENDTRY&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;* Send / Receive Request&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
  &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;send&lt;BR /&gt;
    &lt;STRONG&gt;EXCEPTIONS&lt;/STRONG&gt;&lt;BR /&gt;
      http_communication_failure = 1&lt;BR /&gt;
      http_invalid_state         = 2&lt;BR /&gt;
      http_processing_failed     = 3&lt;BR /&gt;
      http_invalid_timeout       = 4&lt;BR /&gt;
      &lt;STRONG&gt;OTHERS                     &lt;/STRONG&gt;= 5.&lt;BR /&gt;
  &lt;STRONG&gt;IF &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;
    &lt;STRONG&gt;MESSAGE ID &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgid &lt;STRONG&gt;TYPE &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgty &lt;STRONG&gt;NUMBER &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgno&lt;BR /&gt;
               &lt;STRONG&gt;WITH &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv1 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv2 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv3 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv4.&lt;BR /&gt;
  &lt;STRONG&gt;ENDIF&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;receive&lt;/STRONG&gt;&lt;BR /&gt;
    &lt;STRONG&gt;EXCEPTIONS&lt;/STRONG&gt;&lt;BR /&gt;
      http_communication_failure = 1&lt;BR /&gt;
      http_invalid_state         = 2&lt;BR /&gt;
      http_processing_failed     = 3&lt;BR /&gt;
      &lt;STRONG&gt;OTHERS                     &lt;/STRONG&gt;= 4.&lt;BR /&gt;
  &lt;STRONG&gt;IF &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;
    &lt;STRONG&gt;MESSAGE ID &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgid &lt;STRONG&gt;TYPE &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgty &lt;STRONG&gt;NUMBER &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgno&lt;BR /&gt;
               &lt;STRONG&gt;WITH &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv1 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv2 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv3 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv4.&lt;BR /&gt;
  &lt;STRONG&gt;ENDIF&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;* Display result&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
  &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;response&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_status&lt;BR /&gt;
    &lt;STRONG&gt;IMPORTING&lt;/STRONG&gt;&lt;BR /&gt;
      &lt;STRONG&gt;code &lt;/STRONG&gt;= l_status_code.&lt;BR /&gt;
  &lt;STRONG&gt;WRITE &lt;/STRONG&gt;/ |{ l_status_code }|.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;STRONG&gt;WRITE &lt;/STRONG&gt;/.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;STRONG&gt;IF &lt;/STRONG&gt;l_status_code = 200.&lt;BR /&gt;
    &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;response&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_cdata&lt;BR /&gt;
      RECEIVING&lt;BR /&gt;
        &lt;STRONG&gt;data &lt;/STRONG&gt;= l_response_data.&lt;BR /&gt;
&lt;BR /&gt;
    &lt;STRONG&gt;DATA&lt;/STRONG&gt;(l_content_type) = lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;response&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_content_type( ).&lt;BR /&gt;
    &lt;STRONG&gt;IF &lt;/STRONG&gt;l_content_type &lt;STRONG&gt;CP &lt;/STRONG&gt;'text/html*'.&lt;BR /&gt;
      cl_demo_output&lt;STRONG&gt;=&amp;gt;&lt;/STRONG&gt;display_html( html = l_response_data ).&lt;BR /&gt;
    &lt;STRONG&gt;ELSEIF &lt;/STRONG&gt;l_content_type &lt;STRONG&gt;CP &lt;/STRONG&gt;'text/xml*'.&lt;BR /&gt;
      cl_demo_output&lt;STRONG&gt;=&amp;gt;&lt;/STRONG&gt;display_xml( xml = l_response_data ).&lt;BR /&gt;
    &lt;STRONG&gt;ELSEIF &lt;/STRONG&gt;l_content_type &lt;STRONG&gt;CP &lt;/STRONG&gt;'application/json*'.&lt;BR /&gt;
      cl_demo_output&lt;STRONG&gt;=&amp;gt;&lt;/STRONG&gt;display_json( json = l_response_data ).&lt;BR /&gt;
    &lt;STRONG&gt;ENDIF&lt;/STRONG&gt;.&lt;BR /&gt;
  &lt;STRONG&gt;ELSE&lt;/STRONG&gt;.&lt;BR /&gt;
    &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;response&lt;STRONG&gt;-&amp;gt;&lt;/STRONG&gt;get_header_fields&lt;BR /&gt;
      &lt;STRONG&gt;CHANGING&lt;/STRONG&gt;&lt;BR /&gt;
        &lt;STRONG&gt;fields &lt;/STRONG&gt;= lt_fields.&lt;BR /&gt;
&lt;BR /&gt;
    &lt;STRONG&gt;LOOP AT &lt;/STRONG&gt;lt_fields &lt;STRONG&gt;ASSIGNING &lt;/STRONG&gt;&amp;lt;ls_field&amp;gt;.&lt;BR /&gt;
      &lt;STRONG&gt;WRITE&lt;/STRONG&gt;: / &amp;lt;ls_field&amp;gt;&lt;STRONG&gt;-&lt;/STRONG&gt;name, 25 &amp;lt;ls_field&amp;gt;&lt;STRONG&gt;-value&lt;/STRONG&gt;.&lt;BR /&gt;
    &lt;STRONG&gt;ENDLOOP&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
  &lt;STRONG&gt;ENDIF&lt;/STRONG&gt;.&lt;BR /&gt;
&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;* Close HTTP client&lt;/EM&gt;&lt;BR /&gt;
&lt;EM&gt;**********************************************************************&lt;/EM&gt;&lt;BR /&gt;
  &lt;STRONG&gt;CALL METHOD &lt;/STRONG&gt;lo_http_client&lt;STRONG&gt;-&amp;gt;close&lt;/STRONG&gt;&lt;BR /&gt;
    &lt;STRONG&gt;EXCEPTIONS&lt;/STRONG&gt;&lt;BR /&gt;
      http_invalid_state = 1&lt;BR /&gt;
      &lt;STRONG&gt;OTHERS             &lt;/STRONG&gt;= 2.&lt;BR /&gt;
  &lt;STRONG&gt;IF &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;
    &lt;STRONG&gt;MESSAGE ID &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgid &lt;STRONG&gt;TYPE &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgty &lt;STRONG&gt;NUMBER &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgno&lt;BR /&gt;
               &lt;STRONG&gt;WITH &lt;/STRONG&gt;sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv1 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv2 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv3 sy&lt;STRONG&gt;-&lt;/STRONG&gt;msgv4.&lt;BR /&gt;
  &lt;STRONG&gt;ENDIF&lt;/STRONG&gt;.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Best regards,&lt;/P&gt;
  &lt;P&gt;Georg&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:53:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529733#M2005349</guid>
      <dc:creator>georg_w_</dc:creator>
      <dc:date>2021-11-25T07:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Token-based oAuth2 call using authorization code flow (via the SAP OAuth 2.0 client)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529734#M2005350</link>
      <description>&lt;P&gt;See SAP note 3041322 - OAuth 2.0 Client: Downport of grant type Client Credentials&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 08:48:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529734#M2005350</guid>
      <dc:creator>larshp</dc:creator>
      <dc:date>2022-01-20T08:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Token-based oAuth2 call using authorization code flow (via the SAP OAuth 2.0 client)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529735#M2005351</link>
      <description>&lt;P&gt;Hello Lars,&lt;/P&gt;&lt;P&gt;thank you very much for the hint. The class CL_OAUTH2_CLIENT should have a method lo_oa2c_client-&amp;gt;execute_cc_flow to start the Client Credential Flow after applying the correction instruction of the support package. In fact, I haven't tried it, just checked that the prerequisites (kernel 7.53) are met.&lt;/P&gt;&lt;P&gt;Because the implementation should be realized quickly and I didn't know the SAP note yet, I instead executed two HTTP requests via cl_http_client=&amp;gt;create_by_url(), mo_client-&amp;gt;send(), mo_client-&amp;gt;receive() and mo_client-&amp;gt;close( &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;1) Obtaining a token&lt;/P&gt;&lt;P&gt;2) Calling up the web application&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Georg&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 15:51:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529735#M2005351</guid>
      <dc:creator>georg_w_</dc:creator>
      <dc:date>2022-02-15T15:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Token-based oAuth2 call using authorization code flow (via the SAP OAuth 2.0 client)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529736#M2005352</link>
      <description>&lt;P&gt;It would probably have been easier to implement using the method lo_oa2c_client-&amp;gt;execute_cc_flow&lt;/P&gt;</description>
      <pubDate>Tue, 15 Feb 2022 15:54:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529736#M2005352</guid>
      <dc:creator>georg_w_</dc:creator>
      <dc:date>2022-02-15T15:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Token-based oAuth2 call using authorization code flow (via the SAP OAuth 2.0 client)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529737#M2005353</link>
      <description>&lt;P&gt;Hi everyone, &lt;/P&gt;&lt;P&gt;I am in similar situation like above, and have resolved many issues and started working on program to make it work. &lt;/P&gt;&lt;P&gt;I implemented the above note 3041322  and all its dependent notes.&lt;/P&gt;&lt;P&gt;I have tested from OA2C_GRANT_APP and it shows green. Now I want to implement using a program. &lt;/P&gt;&lt;P&gt;Scenario 1:&lt;/P&gt;&lt;P&gt;I tested OA2C_GRANT_APP and before the token is expired, I test my program.&lt;U&gt; This produces the required result&lt;/U&gt; and it get the content from share point (my end point is share point here ). &lt;/P&gt;&lt;P&gt;Scenario 2:&lt;/P&gt;&lt;P&gt;I delete the token in OA2C_GRANT_APP simulating a expired token or brand new request for new token. I have followed the program steps as mentioned in similar blogs. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;the initial step set_token() raises an exception cx_oa2c_at_not_available, 
so I called execute_cc_flow() ; but this raises an exception CX_OA2C_NOT_ALLOWED. 
Before implementing the note, i tried execute_refresh_flow(), that too didnt work at this step. 
So I tried calling set_token() again which gives me CX_OA2C_AT_NOT_AVAILABLE. &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My question is do we need to keep the initial token generated from the OA2C_GRANT_APP? Does anyone have similar issue in getting response from Sharepoint API or other APIs? &lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 01:51:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/token-based-oauth2-call-using-authorization-code-flow-via-the-sap-oauth-2-0/m-p/12529737#M2005353</guid>
      <dc:creator>anandsap</dc:creator>
      <dc:date>2022-03-23T01:51:23Z</dc:date>
    </item>
  </channel>
</rss>

