Authentication
ShipAny currently supports three login methods: Google Login / Google One-Tap Login / Github Login.
Other login methods will be integrated gradually. You can also refer to the next-auth documentation to implement them yourself.
Generate Auth Secret
Run in terminal:
openssl rand -base64 32
This generates a 32-byte random string to use as Auth Secret
Modify the AUTH_SECRET
value in your environment variables:
AUTH_SECRET = "xxx"
Google Login
- Sign in to Google Cloud Console
Create a new project, go to the Credentials management page of the new project, and create an OAuth Client ID
- Configure the necessary callback information according to your project’s port and production domain
https://localhost:3000/api/auth/callback/google
After creating the OAuth Client ID, you’ll receive a Client ID and Client Secret
- Modify
AUTH_GOOGLE_ID
andAUTH_GOOGLE_SECRET
in your configuration file
Enable Google login:
AUTH_GOOGLE_ID = "4680xx-xxx.apps.googleusercontent.com"
AUTH_GOOGLE_SECRET = "GOxxx"
NEXT_PUBLIC_AUTH_GOOGLE_ENABLED = "true"
Google One-Tap Login
First, follow the Google login steps to obtain AUTH_GOOGLE_ID
and AUTH_GOOGLE_SECRET
Modify NEXT_PUBLIC_AUTH_GOOGLE_ONE_TAP_ENABLED
and NEXT_PUBLIC_AUTH_GOOGLE_ID
in your configuration file
Enable Google One-Tap login:
NEXT_PUBLIC_AUTH_GOOGLE_ONE_TAP_ENABLED = "true"
NEXT_PUBLIC_AUTH_GOOGLE_ID = "4680xx-xxx.apps.googleusercontent.com"
The
NEXT_PUBLIC_AUTH_GOOGLE_ID
used for Google One-Tap login should be the same as theAUTH_GOOGLE_ID
configured for Google login.
Github Login
Create a new OAuth app
- Fill in the OAuth app configuration information
https://localhost:3000/api/auth/callback/github
For development and production environments, you need to create two different OAuth apps with different callback URLs.
-
Enter the OAuth app, copy the
Client ID
andClient Secret
-
Modify
AUTH_GITHUB_ID
andAUTH_GITHUB_SECRET
in your configuration file
Enable Github login:
AUTH_GITHUB_ID = "xxx"
AUTH_GITHUB_SECRET = "xxx"
NEXT_PUBLIC_AUTH_GITHUB_ENABLED = "true"
Login Preview
- Click the login button to open the login popup
- When users enter the homepage, they’ll be prompted with one-tap login