Idea

4
Replies
390
Views
yapj1 Member since 2015 32 posts
PEGA
Posted: 3 years ago
Last activity: 2 years 11 months ago

Does Pega 7.2.2 support consuming REST services using OAuth 2.0?

Hi,

I am trying to configure Pega to consume some REST services from an external application, which is using OAuth 2.0. We are provided with a certificate and was told that the Web API is using Certificate Authentication.

When filling up the form, I am not able fill in the required parameter of "Identifier*" and "Secret*":

May I know if Pega 7.2.2 supports Certificate Authentication? i.e. we just pass across the certificate to authenticate? The following is the sample code provided to us:

@@@@@@@@@@@@@@@@@

Sample code snippet from C# on how client calls to get the token:

Client:

//TokenURL will be your API for us to authenticate and get the token

var httpRequest = (HttpWebRequest)WebRequest.Create(TokenURL);

httpRequest.Method = "POST";

httpRequest.Accept = "application/json";

httpRequest.ContentType = "application/x-www-form-urlencoded";

var cert = X509Certificate.CreateFromCertFile(certPath);

//below line is the part we attach cert to the httpRequest

httpRequest.ClientCertificates.Add(cert);

string postData = "grant_type=certificate";

byte[] dataArray = Encoding.UTF8.GetBytes(postData);

// set content length

httpRequest.ContentLength = dataArray.Length;

try

{

// Write to stream

using (Stream requestStream = httpRequest.GetRequestStream())

{

requestStream.Write(dataArray, 0, dataArray.Length);

var webResponse = (HttpWebResponse)httpRequest.GetResponse();

if (webResponse.StatusCode == HttpStatusCode.OK)

{

Stream s = webResponse.GetResponseStream();

var sr = new StreamReader(s);

// The token will be retrieved from the responseText and included in the API call to generate video

responseText = sr.ReadToEnd();

}

}

}

@@@@@@@@@@@@@@@@@

Thanks and looking forward to your help!

Regards,

Jacky

Data Integration Security SR Parallel
Share this page LinkedIn