# Not able to get custom provider from session

**URL:** <https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884>\
**Category:** Extending the server\
**Created:** [November 22, 2024, 9:48am UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884 "2024-11-22T09:48:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhaycock](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rhaycock](https://forum.keycloak.org/u/rhaycock)\
**Post date:** [November 22, 2024, 9:48am UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/1 "2024-11-22T09:48:02Z")

</div>

I have a custom UserStorageProvider that is all setup, registered in META-INF and working lovely 🙂

```auto
public class MyFederationProvider implements UserStorageProvider, UserLookupProvider, CredentialInputValidator {

```

I’m trying to access this from a custom authenticator…

```auto
public class KeycloakUserUpdater extends AbstractSetRequiredActionAuthenticator {
    @Override
    public void authenticate(AuthenticationFlowContext context) {
        Set<?> allProviders = context.getSession().getAllProviders(UserStorageProvider.class);
        Set<?> allCustomerProviders = context.getSession().getAllProviders(MyFederationProvider.class);

```

When I debug this, allCustomProviders is size 0 and allProviders is size 1 but IntelliJ tells me that “All elements are null”.

How do I get my provder?

---

<div class="post-metadata">

**Author:** ![rhaycock](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rhaycock](https://forum.keycloak.org/u/rhaycock)\
**Post date:** [November 22, 2024, 4:42pm UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/2 "2024-11-22T16:42:42Z")

</div>

Found it.

The default `create(KeycloakSession)` method returns null.

---

<div class="post-metadata">

**Author:** ![pauloj](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@pauloj](https://forum.keycloak.org/u/pauloj)\
**Post date:** [January 6, 2025, 5:44pm UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/3 "2025-01-06T17:44:20Z")

</div>

I see where you tracked down the default of presumably the factory to return null on the create(Session) based method. Can I ask what you changed to allow for the provider to be created or returned? I am running into a similar situation.

---

<div class="post-metadata">

**Author:** ![rhaycock](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rhaycock](https://forum.keycloak.org/u/rhaycock)\
**Post date:** [January 7, 2025, 9:57am UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/4 "2025-01-07T09:57:16Z")

</div>

Does your factory extend another class? And does the create method, on the super class, return null?

---

<div class="post-metadata">

**Author:** ![pauloj](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@pauloj](https://forum.keycloak.org/u/pauloj)\
**Post date:** [January 7, 2025, 1:09pm UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/5 "2025-01-07T13:09:13Z")

</div>

It does, I was debating just overriding that method, however did you have any issue not having the component model in that method? We have some configuration for the provider that comes from the model. If this is the only place the session only signature would be used its likely okay, so makes me a bit nervous

---

<div class="post-metadata">

**Author:** ![rhaycock](https://avatars.discourse-cdn.com/v4/letter/r/9de0a6/32.png) [@rhaycock](https://forum.keycloak.org/u/rhaycock)\
**Post date:** [January 7, 2025, 1:40pm UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/6 "2025-01-07T13:40:54Z")

</div>

I implement UserStorageProviderFactory which does have the ComponentModel passed into the create method

` T create(KeycloakSession var1, ComponentModel var2);`

---

<div class="post-metadata">

**Author:** ![pauloj](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@pauloj](https://forum.keycloak.org/u/pauloj)\
**Post date:** [January 7, 2025, 2:31pm UTC](https://forum.keycloak.org/t/not-able-to-get-custom-provider-from-session/28884/7 "2025-01-07T14:31:55Z")

</div>

I do as well, however it appears the session based get provider method(s) use the factory create with just session signature
