From 2105d6b0f3781e4ef97e1dd9c513f636dd721982 Mon Sep 17 00:00:00 2001 From: Liron Newman Date: Mon, 21 Nov 2022 20:51:56 +0000 Subject: [PATCH] Add DwD example for "header" and "curl" option. (#144) --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 2bff387..94527a8 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,13 @@ example, the following command uses the PubSub API to list all PubSub topics. $ curl -H "$(oauth2l header --scope pubsub)" https://pubsub.googleapis.com/v1/projects/my-project-id/topics ``` +To send an API request using domain-wide delegation (DwD), for example, to +list `user@example.com`'s Gmail labels: + +```bash +$ curl -H "$(oauth2l header --email user@example.com --credentials service_account_credentials.json --scope https://www.googleapis.com/auth/gmail.labels)" https://gmail.googleapis.com/gmail/v1/users/me/labels +``` + ### curl This is a shortcut command that fetches an access token for the specified OAuth @@ -155,6 +162,14 @@ default). Additional flags after "--" will be treated as curl flags. $ oauth2l curl --scope cloud-platform,pubsub --url https://pubsub.googleapis.com/v1/projects/my-project-id/topics -- -i ``` +To send an API request using domain-wide delegation (DwD), for example, to +list `user@example.com`'s Gmail labels: + +```bash +$ oauth2l curl --email user@example.com --credentials service_account_credentials.json --scope https://www.googleapis.com/auth/gmail.labels --url https://gmail.googleapis.com/gmail/v1/users/me/labels +``` + + ### info Print information about a valid token. This always includes the list of scopes