Calendar
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 19
- Forks
- 7
- Avg merge
- 59m
- Merged PRs (30d)
- 16
Description
Answer
To use Google Calendar with Clerk authentication, you need to enable Google OAuth and request the appropriate calendar scopes. (1)
Required Scopes
When configuring Google as a social connection, include these scopes to access calendar data:
- `https://www.googleapis.com/auth/calendar.readonly%60
- `https://www.googleapis.com/auth/calendar.events.readonly%60
Accessing Calendar Data
Once a user signs in with Google, Clerk stores and manages their OAuth tokens automatically. Use getUserOauthAccessToken to retrieve the access token for making Google Calendar API requests:
'use server'
import { auth, clerkClient } from '@clerk/nextjs/server'
export async function getGoogleToken() {
const { userId } = await auth()
const client = await clerkClient()
const token = await client.users.getUserOauthAccessToken(userId || '', 'oauth_google')
return {
token: token.data[0].token,
}
}
Making Calendar Requests
Use the retrieved token to call the Google Calendar API:
const client = await clerkClient()
const token = await client.users.getUserOauthAccessToken(userId, 'oauth_google')
const accessToken = token.data[0].token
// Code removed for brevity.
const response = await fetch(
`<https://www.googleapis.com/calendar/v3/calendars/$%7BencodeURIComponent(>
calendarId,
) }/events?timeMin=${monthStart.toISOString() }&timeMax=${monthEnd.toISOString() }&singleEvents=true&orderBy=startTime`,
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
)
Clerk automatically keeps access tokens current, so you don't need to handle token refresh manually. For a complete working example, check out the BookMate demo application or its source code on GitHub .
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file, test, or documentation entry point is named. First identify where Google Calendar and Clerk authentication guidance belongs in QCX, then verify the OAuth scopes, token retrieval example, and Calendar API request are appropriate; done means the information is placed in the agreed documentation location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nextjs, typescript
- Domain
- api, authentication, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100