![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
google-auth-wrapper
Advanced tools
Wrapper to simplify google authentication for server side application.
It provides the following methods:
Together these will allow your application to create the required artifacts to be able to interact with the google apis.
As a pre-req you need to need to add set of credentials for your application in the Google developers console as outlined here (Step 1): [https://developers.google.com/drive/v3/web/quickstart/nodejs] (https://developers.google.com/drive/v3/web/quickstart/nodejs)
authorize handles the interaction with the google oauth infrastructure and provides a plugable inteface for providing your own interaction to ask the user to navigate to the required url and to provide the code returned.
The authorize method takes the following parameters:
authCallback has the following signature:
function(url, provideCode)
with the following parameters:
Once authenticated, there will be a file with the same name as your clientSecrets file but with the '.token' file type. For example, if clientSecrets was 'foo' you should end up with:
It should be possible to copy these files and use them with different machines and or directories.
The execute function uses the contents of the files generated by the authorize call. It has the following paramters:
executeAction must be a function with the following paramters:
var googleAuth = require('google-auth-wrapper'); function listMyFiles(auth, google) { var service = google.drive('v3'); service.files.list({ auth: auth, pageSize: 20, space: 'drive', }, function(err, response) { for (var j = 0; j < response.files.length; j++) { console.log(response.files[j].name); } } ); } googleAuth.execute('./', 'client_secret', listMyFiles);
Although it is intended that you can use the plugable aspect of authorize to integrate the authorization step into your app (using GUI or otherwise) you can also do it through simple command line app as follows:
var googleAuth = require('google-auth-wrapper'); var readline = require('readline'); googleAuth.authorize('./', 'client_secret', ['https://www.googleapis.com/auth/drive'], function(url, provideCode) { console.log('Please vist this url, authorize the app and return the code provided', url); var read = readline.createInterface({ input: process.stdin, output: process.stdout }); read.question('What was the code:?', function(code) { read.close(); provideCode(code, function(err) { if (err !== undefined) console.log('err:' + err); }); }); });
In this example the scopes are set so that you have full read/write to your google drive:
['https://www.googleapis.com/auth/drive'],
adjust this to request the level of access required.
For this example you will to have to have stored your credentials from google in the file 'client_secret.json' and the refresh token created by the authorize call will have been stored in 'client_secret.token'. NOTE make sure to protect these two files appropriately as they give full access to whatever access level you have requested.
FAQs
Wrapper to simplify interaction with google oauth apis
The npm package google-auth-wrapper receives a total of 4 weekly downloads. As such, google-auth-wrapper popularity was classified as not popular.
We found that google-auth-wrapper 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.