# Client Secret null after casting

**URL:** <https://devforum.okta.com/t/client-secret-null-after-casting/26040>\
**Category:** OAuth/OIDC\
**Created:** [December 7, 2023, 9:22pm UTC](https://devforum.okta.com/t/client-secret-null-after-casting/26040 "2023-12-07T21:22:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnP](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnP](https://devforum.okta.com/u/johnP)\
**Post date:** [December 7, 2023, 9:22pm UTC](https://devforum.okta.com/t/client-secret-null-after-casting/26040/1 "2023-12-07T21:22:28Z")

</div>

I am creating an OIDC application if one does not already exist. When it doesn’t exist, I am able to use OIDCApplicationBuilder and then use app.getCredentials().getOauthClient() to get client id and client and client secret. I check to see if the application exists using ApplicationApi.listApplications to see if the app already exists. When it does, I can cast the Application type into an OpenIdConnectApplication type, and get the clientId no problem with this method, but the client secret is returning null.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [December 8, 2023, 12:09am UTC](https://devforum.okta.com/t/client-secret-null-after-casting/26040/2 "2023-12-08T00:09:57Z")

</div>

The Client Secret will only be returned to you during its initial creation.

To get it back after that, you’ll need to make a request to [/api/v1/apps/${appId}/credentials/secrets](https://developer.okta.com/docs/reference/api/apps/#list-client-secrets)

---

<div class="post-metadata">

**Author:** ![johnP](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@johnP](https://devforum.okta.com/u/johnP)\
**Post date:** [December 11, 2023, 3:11pm UTC](https://devforum.okta.com/t/client-secret-null-after-casting/26040/3 "2023-12-11T15:11:07Z")

</div>

How is this done through their SDK? I am using v14, so the only thing similar to that endpoint is /api/v1/apps/${appId}/credentials/keys and /api/v1/apps/${appId}/credentials/csrs using the sdk. Any suggestions?

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [December 11, 2023, 11:48pm UTC](https://devforum.okta.com/t/client-secret-null-after-casting/26040/4 "2023-12-11T23:48:59Z")

</div>

If the SDK you are using (I didn’t see you mention which one), you should be able to use the library to make a manual API request to Okta (true for any other Okta endpoints that aren’t covered by the SDK). For example, from our Java SDK docs: [Call other API endpoints | Okta Java Management SDK](https://github.com/okta/okta-sdk-java?tab=readme-ov-file#call-other-api-endpoints)
