![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
headless-google-auth
Advanced tools
Log into a Google account, setting up Google's official library without a browser.
http://localhost:5678
as an authorized redirect URI. If you change the callback URI or port in the options (see below), make sure the new URI is added or the existing URI is altered to match.Once done, you should see a popover that has the client ID and client secret. If you need to get to it again, you can click on the name selected in step 6.
Nightmare is a browser automation toolkit based on Electron. Unlike v0.1.x which used Casper and consequently required several special setup steps, Nightmare is installable and usable via NPM. For most cases, it will Just Work (tm) out of the box.
However, Electron requires a video buffer to be available. If you are using this library on a headless system (eg, a server with no X client, a Docker instance, or a chroot under Crouton), you will need to use a virtual framebuffer to get this library working. More information about this can be found in the Nightmare repository's issues.
Use npm
: npm install headless-google-auth
The exposed method takes an options hash:
5678
.http://localhost:5678
.The callback (or promise resolution) passes up the newly set up Google client and the tokens used to create that client.
If you wanted to get a list of GMail messages (albeit only their IDs and thread IDs), for example:
var headlessAuth = require('headless-google-auth'),
gmail = require('googleapis').gmail('v1');
headlessAuth({
clientId: '[client ID from developer's console]',
clientSecret: '[client secret from developer's console]',
username: 'testemail@gmail.com',
password: 'MySuperSecretPassword',
scopes:[
'https://www.googleapis.com/auth/gmail.readonly',
]
}, function(err, client, tokens){
gmail.users.messages.list({
userId: 'testemail@gmail.com'
}, function(err, messages){
//will print out an array of messages plus the next page token
console.dir(messages);
});
});
If you wanted tog et list of GMail messages like above, but wanted to use promises instead:
var headlessAuth = require('headless-google-auth'),
gmail = require('googleapis').gmail('v1');
var authPromise = headlessAuth({
clientId: '[client ID from developer's console]',
clientSecret: '[client secret from developer's console]',
username: 'testemail@gmail.com',
password: 'MySuperSecretPassword',
scopes:[
'https://www.googleapis.com/auth/gmail.readonly',
]
});
//... other code if needed...
authPromise.then(function(client, tokens){
gmail.users.messages.list({
userId: 'testemail@gmail.com'
}, function(err, messages){
//will print out an array of messages plus the next page token
console.dir(messages);
});
});
Take a look at the Google NodeJS API Client for more information about scopes, authorization schemes, and other API information.
The Nightmare API documentation is also an excellent resource.
There are also other libraries that accomplish something similar to this one. Highlighting the differences:
open
library to open the authorization link in the default (or specified) browser.FAQs
Log into a Google account using OAuth2 without a browser
The npm package headless-google-auth receives a total of 6 weekly downloads. As such, headless-google-auth popularity was classified as not popular.
We found that headless-google-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.