sfc-utils 1.4.195 → 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.
- package/copy/googleauth.js +28 -2
- package/package.json +1 -1
- package/settings.js +3 -3
package/copy/googleauth.js
CHANGED
|
@@ -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
|
|
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
|
|
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
package/settings.js
CHANGED
|
@@ -132,17 +132,17 @@ let getSettings = function () {
|
|
|
132
132
|
storySettings.NewsletterID ||
|
|
133
133
|
storySettings.Custom_Sailthru_ID ||
|
|
134
134
|
defaultNewsletter ||
|
|
135
|
-
|
|
135
|
+
"",
|
|
136
136
|
NEWSLETTER_PROMO:
|
|
137
137
|
storySettings.NewsletterPromo ||
|
|
138
138
|
storySettings.Custom_Signup_Text ||
|
|
139
139
|
defaultNewsletterPromo ||
|
|
140
|
-
|
|
140
|
+
"",
|
|
141
141
|
NEWSLETTER_LEGAL:
|
|
142
142
|
storySettings.NewsletterLegal ||
|
|
143
143
|
storySettings.TOS_Text ||
|
|
144
144
|
defaultNewsletterLegal ||
|
|
145
|
-
|
|
145
|
+
"",
|
|
146
146
|
// Newer things
|
|
147
147
|
RELATED_LINKS_HED: storySettings.Related_Links_Hed,
|
|
148
148
|
SECTION:
|