curved-florist-98287
12/17/2023, 10:33 AMchilly-king-10285
12/17/2023, 10:33 AMchilly-king-10285
12/17/2023, 10:33 AMbash 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: 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: 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.