In the below method,
I'm a bit lost in your code, next time please try to format the code, click on those ... (three dots) on the edit window and you'll find the <> there.
I bet you wanted to give us a bit more details about the problem that you're facing with your code but you haven't finished your sentence.
Locally, most likely the code will use your `gcloud` credentials and you're already authenticated whilst remotely your app isn't authorised / authenticated. You'll have to do the same thing with your App, to invoke the auth sequence before running your code or straight from your code.
I hope this helps.