I am working with google cloud functions in python and I am facing the following difficulties: I don't know how to add a token to the automatically generated endpoint for my HTTP cloud function : Below is the code I deployed :
from flask import Flask, request
from flask_httpauth import HTTPBasicAuth
auth = HTTPBasicAuth()
PROJECT = "projectname"
app = Flask(__name__)
@app.route('/', methods=['PUT', 'POST'])
@auth.login_required
def httpfunction(request):
data = request.stream.read()
return data
The generated URL is :
https://europe-west1-projectname.cloudfunctions.net/httpfunction
I want to add a token to it in order to avoid inappropriate persons to make use it , so basically here I want to avoid POST and PUT requests from unauthorized users. Any ideas how to do this please ?