Best Practices for Handling Token Refresh in Cal.com Integration #18929
Replies: 2 comments 2 replies
-
Hey @vaibhav135! 👋 I'm here to help you out with any bugs, questions, or contributions you need! To handle token refresh in your Cal.com integration using the
Here's a simplified example of how you might implement this: import { useOAuthFlow } from 'path-to-useOAuthFlow';
const MyComponent = () => {
const { isRefreshing, currentAccessToken } = useOAuthFlow({
accessToken: initialAccessToken,
refreshUrl: '/api/auth/calcom/refresh',
clientId: process.env.NEXT_PUBLIC_X_CAL_ID ?? '',
onSuccess: () => {
console.log('Token refreshed successfully');
},
onError: (error) => {
console.error('Error refreshing token:', error);
},
});
// Use currentAccessToken in your application
return <div>Current Access Token: {currentAccessToken}</div>;
}; This setup ensures that your application is notified of new tokens and can handle token refreshes effectively [1][2]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
Closing this issue. Since there was a bug in our backend due to which, cal was not able to get the accessToken in response for the refresh request. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm integrating Cal.com into our Next.js application using the CalProvider component. I have a question about token refresh handling:
When using the CalProvider with an accessToken and refreshUrl:
If the accessToken expires and Cal.com makes a refresh token request to our server through refreshUrl, how can our application be notified of the new token? We want to ensure that subsequent Cal.com operations use the fresh token instead of the expired one.
Specifically:
Thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions