Skip to content

Commit

Permalink
fix: prod environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
didley committed Nov 11, 2024
1 parent 5124993 commit 256cbdf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
20 changes: 15 additions & 5 deletions lib/KindeAuthProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@ global.atob = decode;

export const KindeAuthProvider = ({
children,
config,
}: {
children: React.ReactNode;
config: {
domain: string | undefined;
clientId: string | undefined;
scopes?: string;
};
}) => {
const domain = process.env.EXPO_PUBLIC_KINDE_DOMAIN!;
const clientId = process.env.EXPO_PUBLIC_KINDE_CLIENT_ID!;
const scopes =
process.env.EXPO_PUBLIC_KINDE_SCOPES?.split(" ") ||
DEFAULT_TOKEN_SCOPES.split(" ");
const domain = config.domain;
if (domain === undefined)
throw new Error("KindeAuthProvider config.domain prop is undefined");

const clientId = config.clientId;
if (clientId === undefined)
throw new Error("KindeAuthProvider config.clientId prop is undefined");

const scopes = config.scopes?.split(" ") || DEFAULT_TOKEN_SCOPES.split(" ");

const [isAuthenticated, setIsAuthenticated] = useState<boolean>(false);
const redirectUri = makeRedirectUri({ native: Constants.isDevice });
Expand Down
14 changes: 6 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ pnpm add @kinde/expo

## **Environment variables**

```bash
EXPO_PUBLIC_KINDE_DOMAIN=[yourapp.kinde.com]
EXPO_PUBLIC_KINDE_CLIENT_ID="ApplicationClientId"
// Optional (default: "openid profile email offline")
EXPO_PUBLIC_KINDE_SCOPES="openid profile email offline"
```

The redirection URL is automatically computed using Expo Auth Session `makeRedirectUri` function. You can find more information about this function [here](https://docs.expo.dev/versions/latest/sdk/auth-session/#makeRedirectUri).

## Integrate with your app
Expand All @@ -30,7 +23,12 @@ import { KindeAuthProvider } from '@kinde/expo';

export default function App() {
return (
<KindeAuthProvider>
<KindeAuthProvider config={{
domain: "your-app.kinde.com", // Required
clientId: "your-client-id", // Required
// Optional (default: "openid profile email offline")
scopes: "openid profile email offline",
}}>
<!-- Your application code -->
</KindeAuthProvider>
);
Expand Down

0 comments on commit 256cbdf

Please sign in to comment.