This sample application demonstrates how to Authenticate Users on App Engine Standard.
This application shows how to authenticate to Google Cloud APIs using two different methods. This sample uses Storage as an example, but these methods will work for any Google Cloud API.
- Enable APIs - Enable the Storage API and create a new project or select an existing project.
- Clone the repo and cd into this directory
$ git clone https://github.com/GoogleCloudPlatform/php-docs-samples $ cd php-docs-samples/appengine/php72/auth - Install dependencies via Composer.
Run
php composer.phar install --no-dev(if composer is installed locally) orcomposer install --no-dev(if composer is installed globally). - Run
gcloud app deployto deploy to App Engine.
- Download The Credentials - Click "Go to credentials" after enabling the
APIs. Click "New Credentials" and select "Service Account Key". Create a new
service account, use the JSON key type, and select "Create". Once
downloaded, set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto the path of the JSON key that was downloaded. - Run PHP's built-in web server with the command
php -S localhost:8000and then view the application in your browser at http://localhost:8000.