okta / okta-sdk-dotnet

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
Other
160 stars 100 forks source link

Retrieving SAML Identity Provider metadata.xml Using Okta SDK (.NET) #663

Closed rishigohil closed 7 months ago

rishigohil commented 1 year ago

Describe the feature request?

I came through a scenario where I needed to fetch the SAML Identity Provider metadata.xml using the Okta SDK. IOktaClient contains a method for IdentityProvider operations but I could not locate a way to directly retrieve the metadata.xml document itself.

Although the SDK offers the metadata.xml URL, we require the metadata document for further processing. Has anyone encountered a similar situation or found a workaround to fetch the SAML IdentityProvider metadata.xml via Okta SDK?

Thank you!

New or Affected Resource(s)

[/v1/idps/](https://developer.okta.com/docs/reference/api/idps/)

Provide a documentation link

https://developer.okta.com/docs/reference/api/idps/

Additional Information?

No response

laura-rodriguez commented 1 year ago

Hi @rishigohil,

Thanks for your question. What version of the SDK are you using? Also, did you find the endpoint/API that does what you want in our API documentation? I basically want to know if something's missing in the SDK or if the Okta API doesn't fully support your use case.

rishigohil commented 1 year ago

Hello @laura-rodriguez ,

We currently use GetIdentityProviderAsync to Get the Idp details using Okta.Sdk - 5.6.0. Calling Get Identity Provider API provides us the _links object and the href property would contain the URL to the metadata.xml document for SAML Identity Provider. Do we have the ability to pull metadata documents using SDK or a standalone API that I can call using GetCollection?

image

Thank you.

laura-rodriguez commented 1 year ago

Maybe you can try the following:

1) Get metadata link from _links

var metadataUrl = myIdp.GetProperty<Resource>("_links")?
                .GetProperty<Resource>("metadata")?
                .GetProperty<string>("href");

2) Call the API directly I don't recall if this version of the SDK supports XML files, but if it doesn't, then you'll have to make the call manually.

I suggest you try first via Postman, and once you are sure about what the request looks like, port it to your C# code.

I hope this helps.

rishigohil commented 1 year ago

Yes, we are currently calling it manually but we were looking for a way to perform the same using the SDK to leverage all its internal features like auto-renewing the token. Do you have a method exposed for this operation in the latest version of the SDK or is that something in the works?

Thank you.

laura-rodriguez commented 1 year ago

I see. Unfortunately, if the API doesn't expose a better way to get the metadata, that's currently your only option, regardless of the SDK version.

I suggest filing a feature request to allow the SDK to make requests to links leveraging all its internal features, like auto-renewing the token. We'll monitor it and gauge people's interest.

laura-rodriguez commented 7 months ago

Closing this issue since 5.x is retired. If this is an issue in the current 7.x series, please feel free to reopen.