New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cloudflare-workers-and-google-oauth

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudflare-workers-and-google-oauth - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

package.json
{
"name": "cloudflare-workers-and-google-oauth",
"version": "1.1.0",
"version": "1.1.1",
"description": "Enables easier interfacing with GCS OAuth API for use in Cloudflare Workers",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -11,8 +11,8 @@ # Google OAuth & Cloudflare Workers

```
// import the lib
This is a fully working code snippet showing how to access Google Cloud Storage (GCS) and returning an image to the browser.
```javascript
import GoogleAuth, { GoogleKey } from 'cloudflare-workers-and-google-oauth'
// ensure you have global access to the environment variable representing the PEM-encoded secret
// you downloaded from Google Cloud dashboard for your service account
// Add secret using Wranlger or the Cloudflare dash
export interface Env {

@@ -22,5 +22,29 @@ GCP_SERVICE_ACCOUNT: string;

...
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
const scopes: string[] = ['https://www.googleapis.com/auth/devstorage.full_control']
const googleAuth: GoogleKey = JSON.parse(env.GCP_SERVICE_ACCOUNT)
// Initialize the service
const oauth = new GoogleAuth(googleAuth, scopes)
const token = await oauth.getGoogleAuthToken()
console.log(token)
// Example with Google Cloud Storage
const res = await fetch('https://storage.googleapis.com/storage/v1/b/MY_BUCKET/o/MY_OBJECT.png?alt=media', {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'image/png',
'Accept': 'image/png',
},
})
return new Response(res.body, { headers: { 'Content-Type': 'image/png' } });
},
};
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc