1.2.0 • Published 1 year ago

tcloud-apigw-app-auth-sign v1.2.0

Weekly downloads
-
License
mit
Repository
-
Last release
1 year ago

tcloud-apigw-app-auth-sign

install

npm install tcloud-apigw-app-auth-sign

Getting started

get request

const appAuthSign = require('tcloud-apigw-app-auth-sign')
const headers = appAuthSign.signHeader({
	apiAppKey: 'key',
	apiAppSecret: 'S%$^k932DASF',
	method: 'GET',
	url: '/api/getUser',
    params: {userId: 8},
	headers: {
		accept: 'application/json',
		'x-date': new Date().toUTCString()
		'Content-Type': 'application/json'
	},
	debug: true,
})

console.log(headers.Authorization)
console.log(headers['Content-MD5'])

post request

const appAuthSign = require('tcloud-apigw-app-auth-sign')
const headers = appAuthSign.signHeader({
	apiAppKey: 'key',
	apiAppSecret: 'S%$^k932DASF',
	method: 'POST',
	url: '/api/createPost',
    data: { content: 'some news', author: 'David'},
	headers: {
		accept: 'application/json',
		'x-date': new Date().toUTCString()
		'Content-Type': 'application/json'
	},
	debug: true,
})

console.log(headers.Authorization)
console.log(headers['Content-MD5'])

Variations

License

MIT.