1+ #! /bin/bash
2+
3+ # Copyright 2020 Google LLC
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ # Utility for generating credentials used by tests.
18+
19+ # Union of scopes used by samples
20+ SCOPES=(
21+ " https://www.googleapis.com/auth/drive"
22+ " https://www.googleapis.com/auth/drive.activity"
23+ " https://mail.google.com/"
24+ " https://www.googleapis.com/auth/classroom.courses"
25+ " https://www.googleapis.com/auth/classroom.announcements"
26+ " https://www.googleapis.com/auth/classroom.rosters"
27+ " https://www.googleapis.com/auth/classroom.topics"
28+ " https://www.googleapis.com/auth/classroom.guardianlinks.students"
29+ " https://www.googleapis.com/auth/classroom.coursework.students"
30+ )
31+
32+ if [ -z " $CLIENT_ID_FILE " ]; then
33+ echo " CLIENT_ID_FILE environment not set. Please set and run again."
34+ exit 1
35+ fi
36+
37+ if [ ! -f " $CLIENT_ID_FILE " ]; then
38+ echo " $CLIENT_ID_FILE not found."
39+ exit 1
40+ fi
41+
42+ printf -v EXPANDED_SCOPES ' %s,' " ${SCOPES[@]} "
43+ gcloud auth application-default login \
44+ --client-id-file=client_secret.json \
45+ --scopes=" ${EXPANDED_SCOPES} "
46+
47+ cat " ${HOME} /.config/gcloud/application_default_credentials.json"
0 commit comments