https://github.com/maximemoreillon/oidc-auth
https://github.com/maximemoreillon/oidc-auth
oauth oauth2 oidc
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/maximemoreillon/oidc-auth
- Owner: maximemoreillon
- Created: 2024-09-12T03:27:41.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-07-16T00:41:20.000Z (11 months ago)
- Last Synced: 2025-09-22T09:07:08.671Z (9 months ago)
- Topics: oauth, oauth2, oidc
- Language: TypeScript
- Homepage:
- Size: 108 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OIDC Auth
A simple class that enforces authentication using OpenID Connect / Oauth2.0
## Usage example
```ts
import OidcClient from "@moreillon/oidc-auth"
const { VITE_APP_OIDC_AUTHORITY, VITE_APP_OIDC_CLIENT_ID } = import.meta.env
const oidcClient = new OidcClient({
redirect_uri: `${window.location.origin}/callback`,
authority: VITE_OIDC_AUTHORITY,
client_id: VITE_OIDC_CLIENT_ID,
extraQueryParams: {
audience: VITE_OIDC_AUDIENCE,
},
})
async function main() {
const result = await oidcClient.init()
if (!result) return
const { tokens, user } = result
oidcClient.onTokenRefreshed((tokens) => {
console.log("Token refreshed")
console.log(tokens)
})
}
main()
```