Consume SSG-WSG API in a .NET Application
integration | 2021-04-20
Below is my POC that contains step by step instruction to consume the SSG-WSG API in your .NET application.
1. Create an Account
- Visit SSG WSG Developer Portal and create an account.
2. Create a New App
- After logging in, go to **Dashboard** → **Create New App**.
- **Authentication Options:**
- **Open**: Developers will be issued a unique **Client ID** and **Client Secret** upon app creation.
- **Certificate**: Requires mutual authentication, and developers must provide a certificate.
3. Add API to Subscriptions
Go to **Dashboard** → **Subscriptions** → **Add API**.
4. Generate the key.pem and cert.pem Files
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
5. Upload the cert.pem File
Upload the cert.pem file to your credentials settings in the Dashboard → App Settings → Credentials.
6. Generate a PKCS #12 Certificate
Run the following command to generate the PKCS #12 certificate for your .NET application:
openssl pkcs12 -inkey key.pem -in cert.pem -export -out cert.p12
7. Sample C# Code to Consume API
var handler = new HttpClientHandler();
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.SslProtocols = SslProtocols.Tls12;
var cert = File.ReadAllBytes(@"<path_to>\cert.p12");
var x509cert = new X509Certificate2(cert);
handler.ClientCertificates.Add(x509cert);
var httpClient = new HttpClient(handler);
var response = httpClient.GetAsync("https://api.ssg-wsg.sg/skillsFramework/jobRoles/titles?keyword=air").Result;
if (response.StatusCode == HttpStatusCode.OK)
{
var result = response.Content.ReadAsStringAsync().Result;
}
Console.ReadKey();