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

SAP OData authentication with token

SOLVED
DanZ
Garnet

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.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: SAP OData authentication with token

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

Re: SAP OData authentication with token

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

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.