<@U04UQ68083H> Can you give me an example usage of...
# ory-copilot
c
@chilly-king-10285 Can you give me an example usage of the Ory client javascript SDK?
c
A message from kapa.ai
Sure, here are some examples of how to use the Ory client JavaScript SDK. First, you need to install the SDK. You can do this by running the following command:
Copy code
bash npm install --save @ory/client
Source: [Ory SDK JavaScript](https://www.ory.sh/docs/hydra/sdk/js), [Integrate authentication into React](https://www.ory.sh/docs/getting-started/integrate-auth/react) After installing the SDK, you can import it and configure it as follows:
Copy code
javascript import { Configuration, PublicApi, AdminApi } from "@ory/client"      const hydraPublic = new PublicApi(    new Configuration({    basePath: "<https://public.hydra:4444/>",    }),   )      const hydraAdmin = new AdminApi(    new Configuration({    basePath: "<https://public.hydra:4445/>",    }),   )
Source: [Ory SDK JavaScript](https://www.ory.sh/docs/hydra/sdk/js) Please note that the
/oauth2/auth
and
/oauth2/token
endpoints should not be consumed using this SDK. Instead, use [golang.org/x/oauth2](https://godoc.org/golang.org/x/oauth2). For more information, visit the [Using OAuth2](https://www.ory.sh/docs/hydra/guides/using-oauth2) guide. If you're upgrading to version 1 of the SDK, you can use the following example:
Copy code
javascript import {     Configuration,     OAuth2Api,     IdentityApi,     FrontendApi,   } from "@ory/client"      const config = new Configuration({     basePath: "https://{your-project}.<http://projects.oryapis.com/|projects.oryapis.com/>",     accessToken: process.env.ORY_API_KEY,     baseOptions: {     withCredentials: true, // Important for CORS     timeout: 30000, // 30 seconds     },   })      const ory = {     identity: new IdentityApi(config),     frontend: new FrontendApi(config),     oauth2: new OAuth2Api(config),   }
Source: [SDK V1 upgrade guide](https://www.ory.sh/docs/guides/upgrade/sdk-v1#upgrade-guide) This client needs an API Key to call some of Ory APIs. You can read more about [Authorization with API Keys](https://www.ory.sh/docs/concepts/personal-access-token) to learn more.