Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Sep 11, 2024
1 parent 0d5a84f commit e98b866
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ export function getAuthType() {

export function checkForValidCreds(instanceUrl?: string, token?: string) {
try {
console.log('checking4', instanceUrl, token);
const responseContent = Api.fetch('SitesManager.getSitesIdWithAtLeastViewAccess', {}, {
instanceUrl,
token,
});
console.log('checking4', responseContent, Array.isArray(responseContent), !!responseContent.length);
return Array.isArray(responseContent) && !!responseContent.length;
} catch (error) {
console.log('checking4', error.message, error.stack);
debugLog('checkForValidCreds:', 'failed to get sites ID with parameters', error.stack || error.message);
return false;
}
Expand All @@ -35,6 +38,7 @@ export function setCredentials(request) {
const instanceUrl = username;

const isValidCreds = checkForValidCreds(instanceUrl, token);
console.log('checking4', instanceUrl, token, isValidCreds);

if (!isValidCreds) {
return {
Expand Down
1 change: 1 addition & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function throwUserError(message: string) {
*/
export function throwUnexpectedError(message: string) {
try {
console.log('checking4', 'error!', message);
const time = (new Date()).toString();
const wholeMessage = `An error has occurred - if you need help, please reach out in the Forums here: ${FORUM_URL} or `
+ `contact us by email at [email protected] (in your message, please use Looker Studio in the subject, and copy paste the error message). `
Expand Down
4 changes: 1 addition & 3 deletions tests/appscript/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ describe('api', () => {
},
});

await new Promise((resolve) => setTimeout(resolve, 3000));

// use the mock server's path that forces a random error
const result = await Clasp.run('setCredentials', {
userToken: {
username: `${ tunnel.url }/forced-random-error/`,
token: 'ignored',
token: 'forcedrandomerror',
},
});

Expand Down

0 comments on commit e98b866

Please sign in to comment.