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

Skip to content

Commit afa82de

Browse files
authored
Create Introduction to APIs in Google
1 parent 5c78ca7 commit afa82de

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Introduction to APIs in Google

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

0 commit comments

Comments
 (0)