const {OAuth2Client} = require('google-auth-library'); 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);
FB.init({ appId : '{your-app-id}', cookie : true, xfbml : true, version : '{api-version}' }); FB.login(function(response) { if (response.authResponse) { console.log('Welcome! Fetching your information.... '); FB.api('/me', function(response) { console.log('Good to see you, ' + response.name + '.'); }); } else { console.log('User cancelled login or did not fully authorize.'); } });This code uses the Facebook SDK to authenticate and authorize the user. In conclusion, there are various package libraries available for JavaScript OAuth2, such as 'google-auth-library' and 'Facebook SDK', which can be used to authenticate and authorize users in web applications.