I am encountering an issue while trying to verify the ID token for my client using Google's example. You can find the example code here.
const {OAuth2Client} = require('google-auth-library'); // <-- facing issues here
const client = new OAuth2Client(CLIENT_ID);
async function verify() {
const ticket = await client.verifyIdToken({
idToken: token,
audience: CLIENT_ID,
});
const payload = ticket.getPayload();
const userid = payload['sub'];
}
verify().catch(console.error)
The problem lies in the first line of code where I import the Google Auth library. Importing it this way results in a 404 (Not Found) error because the path is incorrectly interpreted as "localhost/(root)/google-auth-library". On the other hand, providing the complete relative path up to "src" leads to a 'Syntax Error: Unexpected token "<"'.
I am working on an Angular 4 project and have already installed the library using npm. However, I still cannot use the OAuth2Client class without importing it properly. What would be the correct way to import the library?