okta-sdk-nodejs icon indicating copy to clipboard operation
okta-sdk-nodejs copied to clipboard

Example of making arbitrary API calls

Open nbarbettini opened this issue 6 years ago • 2 comments

We should add an example to the readme that demonstrates how to use this client to make arbitrary calls to the Okta API (i.e. endpoints that are not yet officially supported by the library).

For reference, see the SDK readme template here: https://gist.github.com/nbarbettini/c0f44cf08b6d99b39cd59e533842a684#call-other-api-endpoints

nbarbettini avatar Sep 25 '18 15:09 nbarbettini

this would be super helpful!

I'm currently using Axios to make a request to GET /api/v1/apps/${applicationId}/sso/saml/metadata after adding a custom SAML application.

https://developer.okta.com/docs/reference/api/apps/#preview-saml-metadata-for-application

How could I rewrite this using the client?

  async fetchSamlMetadata(application: any): Promise<string> {
    const kid = application.credentials?.signing?.kid;

    const { data: samlMetadata } = await Axios.get(
      `${process.env.OKTA_CLIENT_ORGURL}api/v1/apps/${application.id}/sso/saml/metadata`,
      {
        params: {
          kid,
        },
        headers: {
          'Accept': 'application/xml',
          'Content-Type': 'application/json',
          'Authorization': `SSWS ${process.env.OKTA_CLIENT_TOKEN}`,
        },
      },
    );

    return samlMetadata;
  }

Having the endpoint supported in the library would be great too, but I'm not so sure how to make the arbitrary request

sbauch avatar Feb 08 '20 23:02 sbauch

@sbauch Thank you for you feedback! We are in the process of revisiting all of our readme's and will make sure to include something like this in a future release. Our SDK team will make sure that we allow for arbitrary calls to our API that automatically includes all necessary headers

Internal ref: OKTA-278073

bretterer avatar Feb 14 '20 21:02 bretterer