Giter Club home page Giter Club logo

Comments (12)

devsargam avatar devsargam commented on August 22, 2024

2 things can be done

  • Either use node as a runtime
    or
  • Somehow figure out the actual post request being sent

from bounty-hook.

devsargam avatar devsargam commented on August 22, 2024

@hkirat thoughts?

from bounty-hook.

SujithThirumalaisamy avatar SujithThirumalaisamy commented on August 22, 2024

@hkirat thoughts?

I already have that working. But have some questions with it.

from bounty-hook.

hkirat avatar hkirat commented on August 22, 2024

oof.
can we dump somewhere else?
Like some other sheet? Notion?

from bounty-hook.

hkirat avatar hkirat commented on August 22, 2024

Whats ur question @SujithThirumalaisamy ?

from bounty-hook.

devsargam avatar devsargam commented on August 22, 2024

Yeah notion looks promising

from bounty-hook.

SujithThirumalaisamy avatar SujithThirumalaisamy commented on August 22, 2024

Whats ur question @SujithThirumalaisamy ?

It was just a api call. I made it working in the vanila worker as well. But the only thing is we need to generate a refresh oauth token and add it to the env when deploying. It is working so. Is'nt it optimal. Or we can use a service account based authentication. Because the native google sheets api access with the API_KEY will not provide full functionality in the api.

from bounty-hook.

SujithThirumalaisamy avatar SujithThirumalaisamy commented on August 22, 2024
export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
		if (request.method !== 'POST') {
			return new Response('Only POST requests are supported!', { status: 405 });
		}

		const bounty: { name: string; pr: string; amount: string; isDispensed: boolean } = await request.json();
		const requestOptions = {
			method: 'POST',
			redirect: 'follow',
		};

		const res = await fetch(
			`https://oauth2.googleapis.com/token?client_id=${env.CLIENT_ID}&client_secret=${env.CLIENT_SECRET}&refresh_token=${env.REFRESH_TOKEN}&grant_type=refresh_token`,
			requestOptions
		);
		const access_token = await res.json();
		const dataToWrite = JSON.stringify({
			range: 'Sheet1!A1:E1',
			majorDimension: 'ROWS',
			values: [[bounty.name, bounty.pr, bounty.amount, bounty.isDispensed || false]],
		});
		const myHeaders = new Headers({
			'Content-Type': 'application/json',
			Authorization: `Bearer ${access_token.access_token}`,
		});
		const sheetData = {
			method: 'POST',
			headers: myHeaders,
			body: dataToWrite,
			redirect: 'follow',
		};
		try {
			const done = await fetch(
				`https://sheets.googleapis.com/v4/spreadsheets/${env.SPEADSHEET_URL}/values/Sheet1!A1:E1:append?valueInputOption=RAW`,
				sheetData
			);
		} catch (e) {
			// Handle error if necessary
		}

		return new Response('Data successfully written to Google Sheets!');
	},
};

from bounty-hook.

hkirat avatar hkirat commented on August 22, 2024

If notion is easier lets just go with notion

from bounty-hook.

SujithThirumalaisamy avatar SujithThirumalaisamy commented on August 22, 2024

If notion is easier lets just go with notion

That should also use the http2 api underthe hood. Sargam is trying to do that. I am looking if it possible to authenticate with the api using a service account

from bounty-hook.

SujithThirumalaisamy avatar SujithThirumalaisamy commented on August 22, 2024

@hkirat Sargam came up with the notion thing. I also setup the google sheets things. Can raise a PR if wanted. Notion PR LGTM.

from bounty-hook.

hkirat avatar hkirat commented on August 22, 2024

Notion is good enuf for now

from bounty-hook.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.