Registry / auth-security / ra-auth-google

ra-auth-google

JSON →
library3.0.0jsnpmunverified

An auth provider for react-admin v5+ that integrates Google Identity Services (GIS) for sign-in with Google, One Tap, and automatic sign-in. Current stable version is 3.0.0, released November 2024, with monthly updates. Simplifies authentication by providing an authProvider, LoginButton, OneTapButton, and httpClient. Key differentiators: tightly coupled with react-admin, supports client-side GIS features only, and removes the previous useGoogleAuthProvider/GoogleAuthContext in v3.0.0.

npm install ra-auth-google
INSTALL
IMPORT
SIG · RA-AUTH-GOOGLE
R
ra-auth-google
auth-securityjavascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

googleAuthProvider
import { googleAuthProvider } from 'ra-auth-google'
import googleAuthProvider from 'ra-auth-google'
Default import not available; named import only.
googleHttpClient
import { googleHttpClient } from 'ra-auth-google'
const { googleHttpClient } = require('ra-auth-google')
ESM-only package; use named import.
LoginButton
import { LoginButton } from 'ra-auth-google'
Named export for the Sign in with Google button component.
OneTapButton
import { OneTapButton } from 'ra-auth-google'
Named export for the One Tap component.

Minimal setup: configure googleAuthProvider and googleHttpClient with client ID, and use LoginButton as login page.

import { Admin, Resource, Login } from 'react-admin'; import { googleAuthProvider, googleHttpClient, LoginButton } from 'ra-auth-google'; const authProvider = googleAuthProvider({ clientId: process.env.VITE_GOOGLE_CLIENT_ID ?? '', }); const httpClient = googleHttpClient({ clientId: process.env.VITE_GOOGLE_CLIENT_ID ?? '', }); const App = () => ( <Admin authProvider={authProvider} loginPage={LoginButton}> <Resource name="posts" /> </Admin> ); export default App;
Debug
Known issues
breakingv3.0.0 removed `useGoogleAuthProvider` and `GoogleAuthContext` – use `googleAuthProvider` directly instead.
fix
Replace `useGoogleAuthProvider()` with `googleAuthProvider({clientId})` directly.
affects: <3.0.0
breakingv3.0.0 made `googleAuthProvider` and `googleHttpClient` callable without parameters – old pattern `new GoogleAuthProvider(config)` breaks.
fix
Call as function: `googleAuthProvider({clientId})` instead of `new GoogleAuthProvider(config)`.
affects: <3.0.0
breakingv2.0.0 upgraded `react-admin` peer dependency to v5 – incompatible with v4.
fix
Upgrade react-admin to v5 or later.
affects: >=2.0.0
deprecatedv1.0.0 used prop-types, removed in v2.0.0 – not a concern for TypeScript users.
fix
Ensure TypeScript usage; prop-types no longer needed.
affects: 1.0.0
gotchaGoogle Identity Services script must be loaded in index.html for GIS to work.
fix
Add `<script async defer src="https://accounts.google.com/gsi/client"></script>` to your HTML `<head>`.
affects: *
gotchaIn development, VITE_GOOGLE_CLIENT_ID env var must have the `VITE_` prefix to be exposed client-side.
fix
Use `VITE_GOOGLE_CLIENT_ID` instead of `GOOGLE_CLIENT_ID`.
affects: *
Errors
Common errors & fixes
Error: useGoogleAuthProvider is not a function
Upgraded to v3.0.0 where useGoogleAuthProvider was removed.
fix
Import and use `googleAuthProvider` from 'ra-auth-google' directly.
Module not found: Error: Can't resolve 'ra-auth-google'
Package not installed or conflicting react-admin version.
fix
Run `npm install ra-auth-google --save` and ensure react-admin v5+ is installed.
GoogleIdentity: 'client_id' is required
Missing or undefined clientId when calling googleAuthProvider.
fix
Set `VITE_GOOGLE_CLIENT_ID` in .env or pass clientId explicitly.
Error: Cannot read properties of undefined (reading 'google')
Google Identity Services script not loaded before React renders.
fix
Add `<script async defer src="https://accounts.google.com/gsi/client"></script>` to index.html.
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
react-adminrequiredPeer dependency for react-admin Admin component integration
reactrequiredRequired for React components like LoginButton and OneTapButton
Agent activity
15 hits · last 30 days
node
14
OpenAI (training)
1
Resources
ra-auth-google — npm install ra-auth-google · libregistry