gmail-to-exchange365
Version:
Complete Gmail to Exchange 365 migration tool with UI - Migrate emails, attachments, and folders seamlessly
34 lines • 1.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGoogleOAuthClient = getGoogleOAuthClient;
exports.generateGoogleAuthUrl = generateGoogleAuthUrl;
exports.exchangeGoogleCode = exchangeGoogleCode;
exports.refreshGoogleToken = refreshGoogleToken;
const googleapis_1 = require("googleapis");
function getGoogleOAuthClient() {
return new googleapis_1.google.auth.OAuth2(process.env.GOOGLE_CLIENT_ID, process.env.GOOGLE_CLIENT_SECRET, process.env.GOOGLE_REDIRECT);
}
function generateGoogleAuthUrl() {
const oauth = getGoogleOAuthClient();
return oauth.generateAuthUrl({
access_type: "offline",
prompt: "consent",
scope: [
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.labels",
"email",
"profile"
]
});
}
async function exchangeGoogleCode(code) {
const oauth = getGoogleOAuthClient();
const { tokens } = await oauth.getToken(code);
return tokens;
}
function refreshGoogleToken(refreshToken) {
const oauth = getGoogleOAuthClient();
oauth.setCredentials({ refresh_token: refreshToken });
return oauth.refreshAccessToken();
}
//# sourceMappingURL=googleAuth.js.map