Reputation: 267
The following is a simple test to get the OIDC token using gapi client
// example.spec.ts
test("get oidc token", async ({ page }) => {
gapi.load("client", () => {
gapi.client
.init({
apiKey: "*****",
clientId:
"********",
discoveryDocs: [
"https://iamcredentials.googleapis.com/$discovery/rest?version=v1",
],
})
.catch((err) => {
console.error(err);
})
.then(() => {
return gapi.client.request({
path: "https://iamcredentials.googleapis.com/v1/...:generateIdToken",
...
});
})
.catch((err) => {
console.error(err);
})
.then((token) => console.log(`OIDC token ${token}`));
});
});
It won't work as it raises a ReferenceError: gapi is not defined
even though the @types/gapi
are installed.
I've already tried to add "gapi"
/"@types/gapi"
in types
inside the tsconfig.json
file or import 'gapi'
without any success.
Now I'm wondering if it is possible to use the gapi client from Playwright or not.
Upvotes: 0
Views: 157