Skip to Content
avatar image
Former Member

REST Adapter Dynamic Token Authentication

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

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

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 19, 2017 at 07:21 AM

    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());
    		}
    	}
    
    
    Add comment
    10|10000 characters needed characters exceeded