11
Views
7
Comments
Header HMAC Authentication
Service Studio Version
11.10.4 (Build 36716)

Hello All,

I need you support with a business need. I have an application and i want to send sms to my customers, calling the API which is provided by my sms provider. The provider requests HMAC Authentication for the header of the request.

The provider document is this. I understand how to implement the API and how to pass the required details to API too, but my confusion is how to build the Signature in Outsystems as per sms provider requirements. You may find below the provided signature example as the sms provider document.

var message = method + "\n"

             + endpoint + "\n"

             + body + "\n"

             + requestDate;

var signature = crypto.createHmac('sha256', secretKey).update(message).digest('base64');

If i understand correctly,  i should encrypt the signature and for this i have already install the Crypto API but i am not aware how to implement it.

Can you advise/suggest ?

Thanks in advance!


mvp_badge
MVP
Rank: #43

Hello George,

You could implement this logic using an Extension. These allow you to write your own C# code to supplement functionality in your applications. Since your SMS provider offers a C# example, it should be a matter of just creating an Extension and a method with the corresponding signature (string secretKey, string method, string uri, string body, string strDate), copying the code into it, and then invoking it in your OutSystems logic.

I don't usually recommend this, but it seems like a pretty low level function, and there probably won't be much gain in spending the time to convert it to an OutSystems Action, especially when there's already example code available.

Rank: #2775

Thanks for your reply. Can you provide more details in order to be clear to me?

Apologises but i am not aware of this and i am new in outsystems too.

mvp_badge
MVP
Rank: #43


No problem George. I'll try and be as detailed as possible.

When you create OutSystems flows and logic, these are called Actions. They're represented by the flows you see in Service Studio. But there's another way to implement logic in OutSystems and that's using Extensions. When you install Service Studio, it comes bundled with the Integration Studio:

The Integration Studio allows you to create Extensions, and they're snippets of C# code you can implement and then use as normal OutSystems Actions. This allows you to implement more specific code components for your applications.

After creating an Extension, you can design your Actions and their signatures:

And once this is done, you can edit the corresponding C# code:


This will open your C# IDE and allow you to edit the code - this is where you'd use the C# example your SMS provider has supplied. I use Visual Studio. After finishing your code, you can publish it to your OutSystems environment, and it will be available for use in your applications.

If you've never configured Integration Studio, this is a good primer. If my explanation was a little confusing and you'd like another angle, this course lays it out better than me.

Rank: #2775

Thank you very much for your reply and the provided instructions.
The truth is that i have not never use the Integration studio.

I appreciate to provide/guide more details how to implement this request or to provide any test oml based on these requirements.

My difficulty is only how to create the signature.

Rank: #2775

Hello Alfonso,

your support is highly appreciated!

mvp_badge
MVP
Rank: #43

Hi George,

My apologies, it has not been an easy week. I should be able to create a test application for you by the end of the day so you can take a look at the implementation.

mvp_badge
MVP
Rank: #43

Here's an implementation of what we discussed, along with a test page to invoke the logic. You'll still need to configure Integration Studio and an IDE if you want to take a look at the Signature method.

Let me know if you have any questions.

SMSSignature.oap