Skip to content

Commit 1903807

Browse files
committed
try capturing the token error
1 parent aafa923 commit 1903807

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

run/idp-sql/test/system.test.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,28 @@ describe('System Tests', () => {
9494

9595
console.log('Retrieving IDP token...');
9696
const customToken = await admin.auth().createCustomToken('a-user-id');
97-
const response = await got(
98-
`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${IDP_KEY}`,
99-
{
100-
method: 'POST',
101-
retry: {
102-
limit: 5,
103-
statusCodes: [404, 401, 403, 500],
104-
methods: ['POST'],
105-
},
106-
body: JSON.stringify({
107-
token: customToken,
108-
returnSecureToken: true,
109-
}),
110-
}
111-
);
97+
try {
98+
const response = await got(
99+
`https://identitytoolkit.googleapis.com/v1/accounts:signInWithCustomToken?key=${IDP_KEY}`,
100+
{
101+
method: 'POST',
102+
retry: {
103+
limit: 5,
104+
statusCodes: [404, 401, 403, 500],
105+
methods: ['POST'],
106+
},
107+
body: JSON.stringify({
108+
token: customToken,
109+
returnSecureToken: true,
110+
}),
111+
}
112+
);
113+
const tokens = JSON.parse(response.body);
114+
CUSTOM_TOKEN = tokens.idToken;
115+
} catch (err) {
116+
throw Error('IDP Token retrieval failed: ', err);
117+
}
112118

113-
const tokens = JSON.parse(response.body);
114-
CUSTOM_TOKEN = tokens.idToken;
115119
if (!CUSTOM_TOKEN) throw Error('Unable to acquire an IDP token.');
116120

117121
console.log('Retrieved IDP token');

0 commit comments

Comments
 (0)