Step 2: Turn on the Gmail API

Locate Gmail API
in the dialog and click the corresponding toggle, setting it to on.

Click the Google API Console link.

Enter "Gmail API" into the search box and click
on the corresponding entry in the results.

Click the Enable API button.

Return to the Apps Script editor and click the OK button on the
Advanced Google Services dialog.

Step 3: Run the sample

In the Apps Script editor, click Run >
listLabels.

The first time you run the sample, it will prompt you to authorize access:

Click the Continue button.

Click the Accept button.

To view the script's output, click View > Logs.

Great! Check out the further reading section below to learn more.
Bummer.
Check out our troubleshooting
section below for some common errors and solutions.
Report the issue on GitHub and we'll work to fix this quickstart.