Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liammartens/google-cloud-edge-service-account-auth
Google Cloud API service account auth helpers for the Edge runtime
https://github.com/liammartens/google-cloud-edge-service-account-auth
Last synced: 7 days ago
JSON representation
Google Cloud API service account auth helpers for the Edge runtime
- Host: GitHub
- URL: https://github.com/liammartens/google-cloud-edge-service-account-auth
- Owner: LiamMartens
- License: gpl-3.0
- Created: 2023-08-03T15:38:56.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-03T16:01:50.000Z (over 1 year ago)
- Last Synced: 2024-10-18T16:13:19.589Z (18 days ago)
- Language: TypeScript
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# google-cloud-edge-service-account-auth
This library was created for use in Edge Runtimes (such as Cloudflare Workers and Vercel Edge) to interact with the Google Cloud APIs using a service account JSON.
## Usage
```js
import { GoogleAuthClient } from 'google-cloud-edge-service-account-auth';const authClient = new GoogleAuthClient(
{
client_email: '...',
private_key: '...',
},
{ fetch }
);const { access_token } = await authClient.authenticate([
'https://www.googleapis.com/auth/devstorage.full_control',
]);await fetch('https://storage.googleapis.com/storage/v1/b/bucketName/o/', {
headers: [['Authorization', `Bearer ${access_token}`]],
});
```## Configuration Options
The 2nd constructor argument accepts a few configuration options as explained below:
| name | description |
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `fetch` | Used to define the `fetch` implementation |
| `authCache` | Should implement a `GoogleAuthCache` instance (exported by the library). Can be used to cache tokens in a third party library or service. |
| `expiryThresholdSeconds` | Used to determine when to refresh tokens (defaults to `60`) |