https://github.com/colorfulcompany/gas-http-client
Google Apps Script向けのTestableでReasonableなHTTP Client
https://github.com/colorfulcompany/gas-http-client
foundation google-apps-script gsuite urlfetch
Last synced: over 1 year ago
JSON representation
Google Apps Script向けのTestableでReasonableなHTTP Client
- Host: GitHub
- URL: https://github.com/colorfulcompany/gas-http-client
- Owner: colorfulcompany
- License: bsd-2-clause
- Created: 2017-07-11T13:56:03.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-08-10T07:12:49.000Z (almost 3 years ago)
- Last Synced: 2025-01-29T20:09:30.609Z (over 1 year ago)
- Topics: foundation, google-apps-script, gsuite, urlfetch
- Language: JavaScript
- Homepage:
- Size: 172 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GasHttpClient
=============
Simple Google Apps Script UrlFetchApp wrapper supporting message authentication with KaleoJWT
[KaleoSoftware/KaleoJWT: Super simple, portable JWT implementation that supports only SHA256 algo](https://github.com/KaleoSoftware/KaleoJWT)
feature
=======
* request()
* requestJSON()
Usage
=====
Prepare
-------
1. clone this repo
2. clasp init & clasp push
3. deploy this as Library and memo Library ID from Project settings
4. add Library with memoed ID from Script Editor
create Reader from Apps Script Project
--------------------------------------
```javascript
const client = GasHttpClient.createClient(UrlFetchApp, 'https://example.com')
client.opts({
method: 'post',
payload: {
thank: 'you',
very: 'mutch',
exp: new Date('2017-07-22').getTime()
},
withJWT: {
'secret': 'abc',
'headerField': 'X-GAS-JWT',
}
})
const response = client.requestJSON('/post')
```
Note: `requestJSON()` add header `Accept: application/json` and `Content-Type: application/json` automatically.
You can use `opts()`, `headers()` and `buildParam()` or `buildParamJSON()` for tesing of building HTTP request, without deploying to Google Apps Script to do real HTTP request.