cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

SAP OData authentication with token

DanZ
15-Moonstone

SAP OData authentication with token

Hi,

 

is it possible to use the integration runtime SAP oData connector to authenticate via a token?

 

The process will be as followed:

1. Request with username/password to endpoint "GetToken"

2. Response is body with json values where I get my access token

3. Use the access token to authenticate to SAP

 

There is something for CSRF token requests. But I am not sure if this is the same thing. Right now my settings are this:

Authentication type: Fixed

Auth. Server ID: -empty-

Rel. URL for CSRF Get Request: /v1/auth/.../token

CSRF Token Name: acc_token

HTTP Connector Connection Settings:

Username & Password for token endpoint

Base URL, rel. URL as needed for SAP...

 

It worked for my endpoint where no authentication is required. But for this one I've only get a 401 - Unauthorized.

ACCEPTED SOLUTION

Accepted Solutions
Chrischhan
13-Aquamarine
(To:DanZ)

Hello,

 

if I understand you correctly you want to fetch a current token and use it (as ApiKey?) to authenticate yourself to SAP.

If so you can override the service "GetCustomHeaderParameters" on your thing and handle the logic in it and return a matching infotable containing the apikey as result:

 

// TODO: fetch Key/Token
// e.g. const tokenResponse = Resources["ContentLoaderFunctions"].GetJSON(params);
var result = { dataShape: { fieldDefinitions: {} }, rows: [] };

result.dataShape.fieldDefinitions["header"] = {
  name: "apikey",
  baseType: "STRING"
};
result.rows = [{ "apikey": tokenResponse.token }];

 

 

View solution in original post

1 REPLY 1
Chrischhan
13-Aquamarine
(To:DanZ)

Hello,

 

if I understand you correctly you want to fetch a current token and use it (as ApiKey?) to authenticate yourself to SAP.

If so you can override the service "GetCustomHeaderParameters" on your thing and handle the logic in it and return a matching infotable containing the apikey as result:

 

// TODO: fetch Key/Token
// e.g. const tokenResponse = Resources["ContentLoaderFunctions"].GetJSON(params);
var result = { dataShape: { fieldDefinitions: {} }, rows: [] };

result.dataShape.fieldDefinitions["header"] = {
  name: "apikey",
  baseType: "STRING"
};
result.rows = [{ "apikey": tokenResponse.token }];

 

 

Announcements


Top Tags