Skip to content

Instantly share code, notes, and snippets.

View 619frank's full-sized avatar

Frank David 619frank

View GitHub Profile
@619frank
619frank / index.html
Created March 28, 2021 19:33
Add this to the body of the index.html file created by running firebase init hosting
<button id="trigger-cf">Trigger Cloud Run</button>
<div id="firebaseui-auth-container"></div>
<script src="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.js"></script>
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.6.1/firebase-ui-auth.css" />
<script>
document.addEventListener('DOMContentLoaded', function() {
// Initialize the FirebaseUI Widget using Firebase.
let ui = new firebaseui.auth.AuthUI(firebase.auth());
ui.start('#firebaseui-auth-container', {
signInOptions: [
@619frank
619frank / openapi2-functions.yaml
Created March 28, 2021 19:23
Open API Yaml for Google Cloud API Gateway with Firebase Auth
# openapi2-functions.yaml
swagger: '2.0'
info:
title: API_ID optional-string
description: Sample API on API Gateway with a Google Cloud Functions backend
version: 1.0.0
schemes:
- https
produces:
- application/json
@619frank
619frank / main.py
Created March 28, 2021 19:17
Python Cloud Function
def hello_get(request):
# Set CORS headers for the preflight request
if request.method == 'OPTIONS':
# Allows GET requests from any origin with the Content-Type
# header and caches preflight response for an 3600s
headers = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET,PUT,POST,DELETE,PATCH,OPTIONS,HEAD',
'Access-Control-Allow-Headers': 'Content-Type,Authorization',
'Access-Control-Max-Age': '3600'