@adntro/google-cloud-auth
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "@adntro/google-cloud-auth", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Google Cloud auth utilitities (get token from functions, local, etc.)", | ||
@@ -25,3 +25,5 @@ "main": "build/src/index.js", | ||
"pretest": "npm.cmd run compile", | ||
"posttest": "npm.cmd run lint" | ||
"posttest": "npm.cmd run lint", | ||
"prepublish": "npm.cmd run compile", | ||
"publish": "npm.cmd publish --access public" | ||
}, | ||
@@ -28,0 +30,0 @@ "devDependencies": { |
# @adntro/google-cloud-auth | ||
> Google Cloud auth utilitities (get token from functions, local, etc.) | ||
Google Cloud auth utilitities (get token from functions, local, etc.) | ||
[![NPM Version][npm-image]][npm-url] | ||
It makes easy to get a bearer token to use from local to invoked authorized endpoints (Cloud Functions, Cloud Run, etc.), and also | ||
to get that token to invoke a secured resource from another resorce. | ||
## Getting started | ||
Install as a dependency | ||
``` | ||
npm i -S @adntro/google-cloud-auth | ||
``` | ||
- In **local environment** you must have installed `gcloud sdk` (https://cloud.google.com/sdk/docs/install) | ||
- From a function, the service account which executes the code should have permission to invoke the remote function | ||
## Usage | ||
``` | ||
const { getIdToken } = require('@adntro/google-cloud-auth'); | ||
async function invokeEndpoint(url, data) { | ||
const token = await getIdToken(url); | ||
return fetch(url, { | ||
method: 'POST', | ||
body: JSON.stringify(data), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': 'application/json', | ||
'Authorization': 'Bearer ' + token // <-- The idToken | ||
} | ||
}); | ||
} | ||
``` | ||
## License | ||
[MIT](LICENSE) | ||
By Adntro Genetics SL | ||
--- | ||
Made with ❤️ by the Adntro Genetics Developer Team. | ||
> ***NOTE: This is not an official Adntro product.*** | ||
[npm-url]: https://www.npmjs.com/package/@adntro/google-cloud-auth |
Sorry, the diff of this file is not supported yet
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
1
100
48
8345