Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/api/auth/google/callback/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export async function GET(req) {

console.log('Authorization code:', code);

const redirectUri = 'https://your-production-domain.com/api/auth/google/callback';
const redirectUri = 'https://inboxiq-seven.vercel.app/api/auth/google/callback';

const oauth2Client = new google.auth.OAuth2(
process.env.GOOGLE_CLIENT_ID,
Expand Down
156 changes: 2 additions & 154 deletions src/app/api/auth/google/route.js
Original file line number Diff line number Diff line change
@@ -1,162 +1,10 @@
// import { google } from 'googleapis';

// export async function GET(req) {
// try {
// console.log('Redirecting to Google OAuth consent screen');

// const oauth2Client = new google.auth.OAuth2(
// process.env.GOOGLE_CLIENT_ID,
// process.env.GOOGLE_CLIENT_SECRET,
// 'https://localhost:3000/api/auth/google/callback' // The same URL should be set in your Google Cloud console
// );

// const authUrl = oauth2Client.generateAuthUrl({
// access_type: 'offline',
// scope: [
// 'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/userinfo.profile', // User profile scope
// 'https://www.googleapis.com/auth/userinfo.email', // User email scope
// 'https://www.googleapis.com/auth/gmail.modify',
// 'https://www.googleapis.com/auth/gmail.compose',
// 'https://www.googleapis.com/auth/gmail.send',
// 'https://www.googleapis.com/auth/gmail.labels',
// 'https://www.googleapis.com/auth/gmail.compose',
// 'https://www.googleapis.com/auth/gmail.modify',
// 'https://mail.google.com/'
// ],
// prompt: 'consent',
// });

// // Redirect the user to the Google OAuth URL
// return new Response(null, {
// status: 302,
// headers: {
// Location: authUrl,
// },
// });
// } catch (error) {
// console.error('Error during Google OAuth redirection:', error);
// return new Response(JSON.stringify({ error: 'Internal server error' }), {
// status: 500,
// headers: { 'Content-Type': 'application/json' },
// });
// }
// }














// import { google } from 'googleapis';

// export async function GET(req) {
// try {
// console.log('Redirecting to Google OAuth consent screen');

// const redirectUri =
// process.env.NODE_ENV === 'development'
// ? 'http://localhost:3000/api/auth/google/callback' // Development redirect URI
// : 'https://https://inboxiq-seven.vercel.app/api/auth/google/callback'; // Production redirect URI

// const oauth2Client = new google.auth.OAuth2(
// process.env.GOOGLE_CLIENT_ID,
// process.env.GOOGLE_CLIENT_SECRET,
// redirectUri
// );

// const authUrl = oauth2Client.generateAuthUrl({
// access_type: 'offline',
// scope: [
// 'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/userinfo.profile',
// 'https://www.googleapis.com/auth/userinfo.email',
// 'https://www.googleapis.com/auth/gmail.modify',
// 'https://www.googleapis.com/auth/gmail.compose',
// 'https://www.googleapis.com/auth/gmail.send',
// 'https://www.googleapis.com/auth/gmail.labels',
// 'https://mail.google.com/'
// ],
// prompt: 'consent',
// });
// return new Response(null, {
// status: 302,
// headers: {
// Location: authUrl,
// },
// });
// } catch (error) {
// console.error('Error during Google OAuth redirection:', error);
// return new Response(JSON.stringify({ error: 'Internal server error' }), {
// status: 500,
// headers: { 'Content-Type': 'application/json' },
// });
// }
// }







// import { google } from 'googleapis';

// export async function GET(req) {
// try {
// const redirectUri =
// process.env.NODE_ENV === 'development'
// ? 'http://localhost:3000/api/auth/google/callback'
// : 'https://inboxiq-seven.vercel.app/api/auth/google/callback';

// const oauth2Client = new google.auth.OAuth2(
// process.env.GOOGLE_CLIENT_ID,
// process.env.GOOGLE_CLIENT_SECRET,
// redirectUri
// );

// const authUrl = oauth2Client.generateAuthUrl({
// access_type: 'offline',
// scope: [
// 'https://www.googleapis.com/auth/gmail.readonly',
// 'https://www.googleapis.com/auth/userinfo.profile',
// 'https://www.googleapis.com/auth/userinfo.email',
// ],
// prompt: 'consent',
// });

// return new Response(null, {
// status: 302,
// headers: {
// Location: authUrl,
// },
// });
// } catch (error) {
// console.error('Error during Google OAuth redirection:', error);
// return new Response(JSON.stringify({ error: 'Internal server error' }), {
// status: 500,
// headers: { 'Content-Type': 'application/json' },
// });
// }
// }




import { google } from 'googleapis';

export async function GET(req) {
try {

const redirectUri = 'http://inboxiq-seven.vercel.app/api/auth/google/callback';
const redirectUri = 'https://inboxiq-seven.vercel.app/api/auth/google/callback';



const oauth2Client = new google.auth.OAuth2(
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ const Navbar = () => {
</div>
) : (
<Link
href="/api/auth/login"
href="/api/auth/login?returnTo=/dashboard"
className="text-gray-700 dark:text-gray-100 hover:text-blue-500 dark:hover:text-blue-400"
>
Login
</Link>

)}
<ThemeToggle />
</div>
Expand Down
Loading