<@U04UQ68083H> is there a way to programatically v...
# ory-copilot
a
@chilly-king-10285 is there a way to programatically via an API to list/create oidc providers?
c
A message from kapa.ai
Yes, you can programmatically register an OAuth2 and OpenID Connect client using the Ory SDK or REST API. Here is an example of how to do it using the Ory SDK:
Copy code
javascript import { Configuration, OidcApi } from "@ory/client"      const ory = new OidcApi(    new Configuration({    basePath: `https://${process.env.ORY_PROJECT_SLUG}.<http://projects.oryapis.com|projects.oryapis.com>`,    accessToken: process.env.ORY_API_KEY,    }),   )      export async function createOidcDynamicClient() {    const { data } = await ory.createOidcDynamicClient({    oAuth2Client: {    grant_types: ["authorization_code", "refresh_token"],    redirect_uris: ["<https://example.com>"],    scope: "offline openid",    token_endpoint_auth_method: "client_secret_post",    },    })       console.log(data.registration_access_token) // Write this down, it is only sent once!    console.log(data.client_id, data.client_secret /* ... */)   }
The response includes the
registration_access_token
which is needed to manage the client. The token will only be shown once! For more details, you can refer to the [API documentation](https://www.ory.sh/docs/reference/api#tag/oAuth2/operation/createOidcDynamicClient). Please note that this operation does not require authentication. As for listing OIDC providers, the provided sources do not contain information on how to do this programmatically via an API. You may want to refer to the full Ory API documentation for more information.
a
@chilly-king-10285 I dont think this is what I am after, is the above API call the equivalent of this bit of the kratos.yml config:
Copy code
selfservice:
      .....
      methods:
        oidc:
          enabled: true
          config:
            providers:
              - .....
c
A message from kapa.ai
I'm sorry for the confusion. The API call I mentioned earlier is not equivalent to the configuration you provided. The configuration you provided is for setting up OIDC providers in the Ory Kratos configuration file (kratos.yml). This configuration is used to enable and configure the OIDC method for user registration and login. Unfortunately, the provided sources do not contain information on how to programmatically create or list OIDC providers equivalent to the configuration in the kratos.yml file via an API. The Ory Kratos configuration is typically managed via the configuration file and environment variables, not programmatically via an API. For more information on how to configure OIDC providers in Ory Kratos, you can refer to the [Ory Kratos OIDC configuration documentation](https://www.ory.sh/docs/self-hosted/kratos/configuration/oidc).
a
Good bot.