aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/ApiManagers/GeneralGoogleManager.ts27
-rw-r--r--src/server/apis/google/GoogleApiServerUtils.ts16
-rw-r--r--src/server/apis/google/google_project_credentials.json8
3 files changed, 16 insertions, 35 deletions
diff --git a/src/server/ApiManagers/GeneralGoogleManager.ts b/src/server/ApiManagers/GeneralGoogleManager.ts
index 25589ccb5..59d066934 100644
--- a/src/server/ApiManagers/GeneralGoogleManager.ts
+++ b/src/server/ApiManagers/GeneralGoogleManager.ts
@@ -1,5 +1,5 @@
import ApiManager, { Registration } from './ApiManager';
-import { Method, _success } from '../RouteManager';
+import { Method } from '../RouteManager';
import { GoogleApiServerUtils } from '../apis/google/GoogleApiServerUtils';
import RouteSubscriber from '../RouteSubscriber';
import { Database } from '../database';
@@ -72,19 +72,19 @@ export default class GeneralGoogleManager extends ApiManager {
secureHandler: async ({ req, res, user }) => {
try {
const auth = await GoogleApiServerUtils.retrieveOAuthClient(user);
-
+
if (!auth) {
return res.status(401).send('Google credentials missing or invalid.');
}
-
+
const tasks = google.tasks({ version: 'v1', auth });
-
+
const { title, notes, due, status, completed } = req.body;
const result = await tasks.tasks.insert({
tasklist: '@default',
- requestBody: { title, notes, due, status, completed},
+ requestBody: { title, notes, due, status, completed },
});
-
+
res.status(200).send(result.data);
} catch (err) {
console.error('Google Tasks error:', err);
@@ -98,37 +98,22 @@ export default class GeneralGoogleManager extends ApiManager {
subscription: '/refreshGoogle',
secureHandler: async ({ user, req, res }) => {
const code = req.query.code as string;
- console.log('/refreshGoogle hit with code:', code);
try {
const enriched = await GoogleApiServerUtils.processNewUser(user.id, code);
if (enriched.refresh_token) {
- console.log('Enriched credentials:', enriched);
-
if (enriched.refresh_token) {
user.googleToken = enriched.refresh_token;
await user.save();
- console.log('Saved refresh token to user model');
} else {
console.warn('No refresh token returned');
}
}
-
- // await user.save();
- // _success(res, 'Google account successfully linked!');
- res.redirect('/home');
-
} catch (err) {
console.error('Failed to process Google code:', err);
res.status(500).send('Error linking Google account');
}
-
- // const response2 = await Networking.PostToServer('/writeGoogleAccessToken', { authenticationCode });
- // runInAction(() => {
- // this.success = true;
- // this.credentials = response2 as { user_info: { name: string; picture: string }; access_token: string };
- // });
},
});
}
diff --git a/src/server/apis/google/GoogleApiServerUtils.ts b/src/server/apis/google/GoogleApiServerUtils.ts
index 56bc79119..2f7ef473c 100644
--- a/src/server/apis/google/GoogleApiServerUtils.ts
+++ b/src/server/apis/google/GoogleApiServerUtils.ts
@@ -185,18 +185,14 @@ export namespace GoogleApiServerUtils {
*/
export function generateAuthenticationUrl(): string {
const oauth2Client = new google.auth.OAuth2(
- '838617994486-a28072lirm8uk8cm78t7ic4krp0rgkgv.apps.googleusercontent.com',
- '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',
+ '740987818053-dtflji3hfkn5r9t8ad6jb8740pls8moh.apps.googleusercontent.com',
+ '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',
'http://localhost:1050/refreshGoogle' // Ensure this matches the redirect URI in Google Cloud Console
);
return oauth2Client.generateAuthUrl({
access_type: 'offline',
- scope: [
- 'https://www.googleapis.com/auth/tasks',
- 'openid',
- 'profile'
- ],
+ scope: ['https://www.googleapis.com/auth/tasks', 'openid', 'profile'],
prompt: 'consent', // This ensures we get a refresh token
});
}
@@ -220,12 +216,12 @@ export namespace GoogleApiServerUtils {
*/
export async function processNewUser(userId: string, authenticationCode: string): Promise<EnrichedCredentials> {
const credentials = await new Promise<Credentials>((resolve, reject) => {
- worker.getToken(authenticationCode, (err, credentials) => {
- if (err || !credentials) {
+ worker.getToken(authenticationCode, (err, creds) => {
+ if (err || !creds) {
reject(err);
return;
}
- resolve(credentials);
+ resolve(creds);
});
});
const enriched = injectUserInfo(credentials);
diff --git a/src/server/apis/google/google_project_credentials.json b/src/server/apis/google/google_project_credentials.json
index 010f9a626..8abc13b80 100644
--- a/src/server/apis/google/google_project_credentials.json
+++ b/src/server/apis/google/google_project_credentials.json
@@ -1,11 +1,11 @@
{
"installed": {
- "client_id": "838617994486-a28072lirm8uk8cm78t7ic4krp0rgkgv.apps.googleusercontent.com",
- "project_id": "gtasks-test-dash",
+ "client_id": "740987818053-dtflji3hfkn5r9t8ad6jb8740pls8moh.apps.googleusercontent.com",
+ "project_id": "dash-web-461920",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
- "client_secret": "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",
+ "client_secret": "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",
"redirect_uris": ["http://localhost:1050/refreshGoogle"]
}
-} \ No newline at end of file
+}