Skip to Content
0

REST Adapter Dynamic Token Authentication

Dec 19, 2017 at 06:54 AM

144

avatar image
Former Member

Hi Experts,

We have requirement for REST interface where we need to call dynamic token authentication and GET and POST results through the REST Adapter

It would be great if you share the right document/link for dynamic token authentication.

we are using SAP PI 7.4 for integration.

Thank you in Advance,

Regards,

Krushi.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member Dec 19, 2017 at 07:59 AM
0

Hi Fedrick,

Thank you for your prompt response. Yes indeed we need to token authenticate at receiver side. do we need to create a function library or UDF in mapping. can you please Advise?

Regards,

Krushi.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hey Former Member ,

if you want to proceed using an UDF I'd recoment the following blog:

https://blogs.sap.com/2012/11/19/how-to-create-user-defined-function-for-message-mapping-using-nwds/

I'd hook the UDF function into the first graphical mapping step.

If you need futher information on the API functionallity check out the SAP JavaDocs based on your EAI setup

Regards.

Frederick

0
Frederick-Claud Dimmer Dec 19, 2017 at 07:21 AM
0

Hi,

do you need to authenticate the application on the sender or receiver side? If you need to authenticate the application at the receiver side you could implement a JavaMapping that authenticates the client at the server and writes the token to the header of the receiver message. You could use the following mapping skelleton to continue.

package com.xxx.aii.mapping;

import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;

public class MessageMapping extends AbstractTransformation {

	@Override
	public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
		try {
			InputStream is = transformationInput.getInputPayload().getInputStream();
			OutputStream os = transformationOutput.getOutputPayload().getOutputStream();

			/**
			 * TODO:
			 * - copy payload to the TransformationOutput object
			 * - retrieve token from the external server
			 * - write the token to the header of the TransformationOutput
			 */

		} catch (Exception exception) {
			getTrace().addDebugMessage(exception.getMessage());
			throw new StreamTransformationException(exception.toString());
		}
	}

Share
10 |10000 characters needed characters left characters exceeded