Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e599597

Browse files
authored
Create Introduction to APIs in Google Cloud
1 parent 80c35d3 commit e599597

File tree

1 file changed

+37
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)