Prerequisites: • A developer account.
Steps:
-
Create an OAuth App: o Provide a name, homepage URL, (e.g http://localhost:3000) and callback URL (e.g., http://localhost:3000/auth/github/callback). o Note down the Client ID and Client Secret that are generated.
-
Set up Environment Variables: o open .env file in your project's root directory. o Add the following lines, replacing the placeholders with your actual GitHub credentials:
#jwt: JWT_SECRET= mysecret #the secret JWT_AUDIENCE= mycompany #aud in jwt token JWT_ISSUER= mycompany #iss in jwt token
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
GITHUB_CALLBACK_URL= e.g http://localhost:4000/auth/github/callback
GITHUB_AUTH_ROUTE = /auth/github
GITHUB_CALLBACK_ROUTE = /auth/github/callback
GITHUB_SUCCESS_REDIRECT_URL = /verify/user
GITHUB_FAILURE_REDIRECT_URL = /error
GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= GOOGLE_CALLBACK_URL= e.g http://localhost:4000/auth/google/callback GOOGLE_AUTH_ROUTE = /auth/google GOOGLE_SUCCESS_REDIRECT_URL = /verify/user GOOGLE_FAILURE_REDIRECT_URL = /error
LINKEDIN_CLIENT_ID= LINKEDIN_CLIENT_SECRET= LINKEDIN_CALLBACK_URL= e.g http://localhost:4000/auth/linkedin/callback LINKEDIN_AUTH_ROUTE = e.g. /auth/linkedin LINKEDIN_SUCCESS_REDIRECT_URL = /verify/user LINKEDIN_FAILURE_REDIRECT_URL = /error
SESSION_SECRET = your secret
- Configure http.yaml file like this o Add the following configuration under the authn section in src/eventsources/http.yaml authn: oauth2: github: client_id: <% process.env.GITHUB_CLIENT_ID %> client_secret: <% process.env.GITHUB_CLIENT_SECRET %> callback_url: <% process.env.GITHUB_CALLBACK_URL %>