Created
May 6, 2019 03:57
-
-
Save nightbear1009/4c1367eaa016eb3788ea1b963222b72d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { google } = require('googleapis'); | |
const axios = require('axios') | |
test() | |
async function test() { | |
let accessToken = '' | |
const jwtClient = new google.auth.JWT( | |
`aaa@aaaa.iam.gserviceaccount.com`, | |
`aaaa.p12`, | |
null, | |
[`https://www.googleapis.com/auth/cloud-platform`] | |
) | |
jwtClient.authorize((err, token) => { | |
accessToken = token.access_token; | |
console.log(`access_token: ${accessToken}`) | |
const axiosInstance = axios.create({ | |
headers: { | |
'Authorization': `Bearer ${accessToken}` | |
} | |
}) | |
axiosInstance.post( | |
`https://firebase.googleapis.com/v1beta1/projects/xxxx:addFirebase`, | |
{ | |
timeZone: 'America/Los_Angeles', | |
regionCode: 'US', | |
locationId: 'us-central' | |
} | |
).then(res => { | |
console.log(res.data) | |
}).catch(error => { | |
console.log(error.response.data) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment