forked from lavishsheth/code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Introduction to APIs in Google Cloud
37 lines (29 loc) · 1.15 KB
/
Introduction to APIs in Google Cloud
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
gcloud services enable fitness.googleapis.com
gcloud services enable storage-api.googleapis.com
cat > values.json << EOF
{ "name": "$DEVSHELL_PROJECT_ID",
"location": "us",
"storageClass": "multi_regional"
}
EOF
Go to OAuth 2.0 playground
Select Cloud Storage API V1
Select https://www.googleapis.com/auth/devstorage.full_control
Click Authorize APIs
Select your Qwiklabs account and then click Continue
Click Exchange authorization code for tokens
Now copy the access token
export OAUTH2_TOKEN=
export PROJECT_ID=$(gcloud config get-value project)
curl -X POST --data-binary @values.json \
-H "Authorization: Bearer $OAUTH2_TOKEN" \
-H "Content-Type: application/json" \
"https://www.googleapis.com/storage/v1/b?project=$PROJECT_ID"
curl -O demo-image.png https://cdn.qwiklabs.com/E4%2BSx10I0HBeOFPB15BFPzf9%2F%2FOK%2Btf7S0Mbn6aQ8fw%3D
output=$(realpath demo-image.png)
export OBJECT=$output
export BUCKET_NAME=$DEVSHELL_PROJECT_ID
curl -X POST --data-binary @$OBJECT \
-H "Authorization: Bearer $OAUTH2_TOKEN" \
-H "Content-Type: image/png" \
"https://www.googleapis.com/upload/storage/v1/b/$BUCKET_NAME/o?uploadType=media&name=demo-image"