We have an application in App Engine Standard Python 2.7. We also have a Cloud Function in this project.
We would like to do a HTTP POST request to one of the resources in the App Engine application. Currently we have the following code in Cloud Functions
url = "https://project-name.appspot.com/urlidentifier"
data_obj = {
'sample' : 'data'
}
data_json = json.dumps(data_obj)
data_encode = urllib.parse.urlencode(data_json).encode("utf-8")
req = request.Request(url, data=data_encode) # this will make the method "POST"
resp = request.urlopen(req)
Application in Python 2.7 is authenticated using Firebase user authentication. Please see here for details.
Our question - how do we enforce authentication of the application's resource when the HTTP POST is initiated by the Cloud Function (instead of the user). The application resource (https://project-name.appspot.com/urlidentifier) is a function in the project. Can we use service accounts? If yes, how do we do this?
Both the Cloud Function and the application belong to the same project.