Rest Api With Access Token
Rest Api With Access Token
Search …
[SAP CPI] – HOW TO CALL
EXTERNAL REST API WITH
ACCESS TOKEN AND CSRF RECENT
TOKEN IN CPI POSTS
May 12, 2022 Huy NguyenDuc CPI - [SAP
Integration Scenarios, CPI - Tips & Troubleshooting, SAP
S/4HANA
CPI 5 comments
CLOUD] – KEY
Hello guys, in this article I want to share one USER
scenario which in there I used some my EXTENSIBILITY
understand about CSRF-token, access token, send WITH CUSTOM
header value from outside into caller http LOGIC & FIELD
WEBSERVICE. November 27,
2023
First, kindly take look scenarios [SAP CPI] –
HOW TO USE
Scenario 01 MIGRATION
ASSESSMENT
We have one REST API which use access token to
TOOL November
access. We want call this API, we will have do
18, 2023
some action below:
[SAP
Step 1: Call to URL TOKEN to get access token. S/4HANA
In this article, for example TOKEN will get from CLOUD] –
EXTENSIONS
service key. Endpoint : WITH PROCESS
https://<Host>/oauth/token AUTOMATION
Step 2: Use access token in step 1 to call REST September 27,
API. In this article endpoint : 2023
https://<host>/http/restapi [SAP
S/4HANA
CLOUD] –
DEVELOPER
EXTENSIBILITY
IN S/4 HANA
CLOUD
September 19,
2023
Configuration for Scenario 01 [SAP S/4
HANA CLOUD] –
For simple in this article, I will use integration flow
HOW TO SEND
in CPI to create one REST API and call it from
DATA FROM
another integration.
S/4HANA
Step 1 : Create integration flow with type is REST CLOUD TO
API EXTERNAL BY
OUTPUT TYPE
August 6, 2023
CATEGORIES
ABAP
Common
topics
SAP
SAP BASICS
SAP GUI
SAP IDOC
SAP CLOUD
CONNECTOR
SAP CPI
CPI –
Integration
Scenarios
CPI – Tips &
Troubleshootin
g
SAP FIORI
SAP IDOC
SAP MM
MM-
Inventory
MM-Master
Data
MM-
Material
In this scenario, we do not use CSRF Protected. Resource
Planning
Save and deploy this REST API
MM-
Purchasing
Test this API from POSTMAN, we need to check
MM-Tips &
this API run OK.
Troubleshootin
g
SAP POS DM
| CAR
CAR Fiori
Apps
CAR-Books
As we see, this API need authorize by OAUTH2
CAR-
with grant type is Client Credentials. So, we need
Demand Data
call to token provider to get access token.
Foundation
All information of token provider will be get from CAR-
service key with type Process Integration Runtime. Inventory
Visibility
CAR-
Ommnichann
el Article
Availability
CAR-
Omnichannel
Promotion
Pricing
CAR-On-
Shelf
Availability
CAR-POS
Step 2 : Create integration flow call REST API in
DTA
Step 01
CAR-Tips &
In this step, we will create new integration flow will Troubleshootin
call REST API in step 01. We also focus that, REST g
API use access token to call, so in integration flow CAR-
we need call to token provider to get access token Unified
and after that will use this access token to call Demand
REST API. All this things, we will action on Forecast
integration flow. SAP
Consumer
Step 2.1 : Create integration flow with sender Sales
adapter is HTTP Intelligence
SAP POSDM-
CAR
SAP PP
SAP Process
Integration (old)
SAP Process
Orchestration
SAP PO –
Integration
We will have two ways to call REST API which use concepts
OATHAU2 for credentials. First way, we will create SAP PO-
OAUTH2 Client Credential in CPI and use it to call Integration
direct to REST API. The second way, we will call scenarios
manual to Token provider to get access token, and SAP PO-
after that use this access token to call REST API Tips &
Troubleshootin
Step 2.2: First way – Create OAUTH2 client g
Credential in CPI SAP Sales &
Distribution
Go to Security Material in section Manage
IS Retails
Security
IS-
Business
Process/Busi
ness
Scenario
IS-
Configuratio
n
Manufacturing
Create button -> OAuth2 Client Credentials
M-
Business
Process/Busi
ness
Scenario
M-
Configuratio
n
SD-Tips &
Troubleshootin
g
SAP.BASIS
Uncategorized
ARCHIVES
November
2023
September
(1) – (2) – (3) : Get from service key because this 2023
REST API created from SAP CPI for example. In August 2023
fact, API owner will provide these information. July 2023
(4) : Send as Request Header for example in June 2023
this article. In fact, base on configure of API May 2023
Owner. April 2023
February
Next, We will use component Request Reply to 2023
call direct REST API with Authentication Type is January 2023
OAuth2 Client Credentials and input name of December
Oauth2 client credentials above in here 2022
November
2022
October 2022
September
2022
August 2022
July 2022
June 2022
May 2022
April 2022
Step 2.2: Second way – Use access token to call March 2022
REST API November
2021
The first, we try call API which provided by Token
October 2021
Provider by POSTMAN to understand how to
September
2021
Token provider will provide information August 2021
July 2021
Token URL May 2021
client_id : in this article, get it from service key. April 2021
In fact, this value partner will provide March 2021
client_secret : in this article get it from service January 2021
key. In fact this value partner will provide November
Content-type : x-www-form-urlencoded 2020
response_type : token October
grant_type : client_credentials 2020
June 2020
May 2020
April 2020
March 2020
January 2020
December
2019
OK, let configure this on SAP CPI integration flow
November
Step 2.2.1: Add content modifier and add header, 2019
body October 2019
September
Add content modifier 2019
August 2019
July 2019
June 2019
May 2019
March 2019
February
Add header 2019
grant_type : client_credentials January 2019
response_type : token October 2018
Content-Type : application/x-www- September
form-urlencoded 2018
client_id
client_serect
Next, because this REST API use content-type =
x-www-form-urlendcoded. So we will create
body for request with syntax :
Key1=Value1&Key2=Value2&Key3=Value3
Key : Authorization
Value : Bearer <access_token>
For example
Summary
In this article I shared step by step one scenario
call external REST API with authorization by use
Oauth2. Access token will be gotten from Token
provider by Client ID, Client Secret, Token URL. If
external REST API also use more one token called
X-CSRF-TOKEN to protect API, We also can get
more CSRF token and call REST API with access
token. Thanks for your reading and hope this
article useful. If have any advise, kindly leave your
comment on this. Thanks.
Joseph.
5 COMMENTS
Sandeep says:
May 13, 2022 at 9:25 pm
Excellent blog.
Please keep blogging on more on CPI .
Like
Reply
Thanks Sandeep
Like
Reply
katetsan says:
June 13, 2022 at 2:31 pm
Thanks in advance
Like
Reply
khushi says:
February 17, 2023 at 5:34 pm
Like
Reply
Like
Reply
LEAVE A REPLY