Created
January 13, 2023 20:38
-
-
Save ChristianOConnor/e250cdda91f5a2521b23188d78c84326 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var express = require("express"); | |
var app = express(); | |
require("dotenv").config(); | |
const GoogleAuth = require("google-auth-library").GoogleAuth; | |
const cors = require("cors"); | |
app.use( | |
cors({ origin: process.env.ORIGIN, credentials: process.env.CREDENTIALS }) | |
); | |
app.get("/hello", async function (req, res) { | |
const keyInJsn = JSON.parse(process.env.CREDENTIALS_STR); | |
const auth = new GoogleAuth({ | |
credentials: keyInJsn, | |
}); | |
const url = process.env.RUN_APP_URL; | |
//Create your client with an Identity token. | |
const client = await auth.getIdTokenClient(url); | |
const result = await client.request({ url }); | |
const resData = result.data; | |
res.send(resData); | |
}); | |
var server = app.listen(8081, function () { | |
var host = server.address().address; | |
var port = server.address().port; | |
console.log("Example app listening at http://localhost:", port); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment