sfc-utils 1.4.196 → 1.4.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/copy/googleauth.js +28 -2
  2. package/package.json +1 -1
@@ -46,8 +46,12 @@ var fallbackAuth = function () {
46
46
  };
47
47
 
48
48
  var authenticate = function ({ fallback }) {
49
+ console.log("\n========== GOOGLEAUTH: authenticate() called ==========");
50
+ console.log("GOOGLEAUTH: fallback parameter =", fallback);
51
+
49
52
  if (fallback) {
50
53
  return new Promise((resolve, reject) => {
54
+ console.log("GOOGLEAUTH: Using fallback auth path");
51
55
  console.log(
52
56
  "Service account failed, falling back to regular token (to use the service account, share this sheet or doc with sfchronicle-gatsby@zinc-proton-250521.iam.gserviceaccount.com)"
53
57
  );
@@ -57,14 +61,23 @@ var authenticate = function ({ fallback }) {
57
61
  // Try to use the service account first
58
62
  return new Promise((resolve, reject) => {
59
63
  try {
64
+ console.log("GOOGLEAUTH: Attempting service account authentication...");
65
+
60
66
  // If it's coming from EC2, pull from project
61
67
  if (process.env.GOOGLE_OAUTH_SYSTEM === "EC2") {
62
68
  serviceAccountCreds = "../service-account-google-creds.json";
63
69
  }
64
70
 
71
+ console.log("GOOGLEAUTH: Loading credentials from:", serviceAccountCreds);
72
+
65
73
  var serviceAccountJSON = fs.readFileSync(serviceAccountCreds, "utf-8");
66
74
  serviceAccountJSON = JSON.parse(serviceAccountJSON);
67
75
 
76
+ console.log(
77
+ "GOOGLEAUTH: Service account email:",
78
+ serviceAccountJSON.client_email
79
+ );
80
+
68
81
  // configure a JWT auth client
69
82
  let jwtClient = new google.auth.JWT(
70
83
  serviceAccountJSON.client_email,
@@ -75,20 +88,33 @@ var authenticate = function ({ fallback }) {
75
88
  "https://www.googleapis.com/auth/drive",
76
89
  ]
77
90
  );
91
+
92
+ console.log("GOOGLEAUTH: JWT client created, authorizing...");
93
+
78
94
  //authenticate request
79
95
  jwtClient.authorize(function (err, tokens) {
80
96
  if (err) {
81
- console.log("Stage 1 error, fallback auth");
97
+ console.log("GOOGLEAUTH: Stage 1 error during jwtClient.authorize()");
98
+ console.log("GOOGLEAUTH: Error details:", err.message || err);
82
99
  resolve(fallbackAuth());
83
100
  } else {
84
101
  console.log("Successfully connected to service account!");
102
+ console.log(
103
+ "GOOGLEAUTH: Token type:",
104
+ tokens ? tokens.token_type : "unknown"
105
+ );
106
+ console.log(
107
+ "GOOGLEAUTH: Token expires:",
108
+ tokens ? tokens.expiry_date : "unknown"
109
+ );
85
110
  // Return the jwtClient as auth
86
111
  resolve(jwtClient);
87
112
  }
88
113
  });
89
114
  } catch (err) {
90
115
  // It's ok if it errors, we have the fallback
91
- console.log("Stage 2 error, fallback auth");
116
+ console.log("GOOGLEAUTH: Stage 2 error (catch block)");
117
+ console.log("GOOGLEAUTH: Error details:", err.message || err);
92
118
  resolve(fallbackAuth());
93
119
  }
94
120
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfc-utils",
3
- "version": "1.4.196",
3
+ "version": "1.4.197",
4
4
  "author": "ewagstaff <evanjwagstaff@gmail.com>",
5
5
  "dependencies": {
6
6
  "archieml": "^0.4.2",