@google-cloud/nodejs-common 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install_functions.sh +15 -4
- package/package.json +1 -1
package/bin/install_functions.sh
CHANGED
|
@@ -1337,10 +1337,13 @@ do_authentication(){
|
|
|
1337
1337
|
do_oauth(){
|
|
1338
1338
|
# Base url of Google OAuth service.
|
|
1339
1339
|
OAUTH_BASE_URL="https://accounts.google.com/o/oauth2/"
|
|
1340
|
+
# Redirect uri.
|
|
1341
|
+
# Must be the same for requests of authorization code and refresh token.
|
|
1342
|
+
REDIRECT_URI="http%3A//127.0.0.1%3A8887"
|
|
1340
1343
|
# Defaulat parameters of OAuth requests.
|
|
1341
1344
|
OAUTH_PARAMETERS=(
|
|
1342
1345
|
"access_type=offline"
|
|
1343
|
-
"redirect_uri
|
|
1346
|
+
"redirect_uri=${REDIRECT_URI}"
|
|
1344
1347
|
"response_type=code"
|
|
1345
1348
|
)
|
|
1346
1349
|
while [ ${#ENABLED_OAUTH_SCOPES[@]} -eq 0 ]; do
|
|
@@ -1409,18 +1412,26 @@ EOF
|
|
|
1409
1412
|
printf '%s\n' "3. Open the link in browser and finish authentication: \
|
|
1410
1413
|
${auth_url}"
|
|
1411
1414
|
cat <<EOF
|
|
1412
|
-
Note:
|
|
1415
|
+
Note:
|
|
1416
|
+
If the OAuth client is not for a native application, there will be an \
|
|
1413
1417
|
"Error 400: redirect_uri_mismatch" shown up on the page. In this case, press \
|
|
1414
1418
|
"Enter" to start again with a native application OAuth client ID.
|
|
1419
|
+
If there is no local web server serving at ${REDIRECT_URI}, the \
|
|
1420
|
+
succeeded OAuth flow will land the browser on an error page ("This site can't \
|
|
1421
|
+
be reached"). This is an expected behavior. Copy the whole URL and continue.
|
|
1422
|
+
|
|
1415
1423
|
EOF
|
|
1416
|
-
printf '%s' "4. Copy the authorization code
|
|
1424
|
+
printf '%s' "4. Copy the authorization code or complete url from browser \
|
|
1425
|
+
and paste here: "
|
|
1417
1426
|
read -r auth_code
|
|
1418
1427
|
if [[ -z ${auth_code} ]]; then
|
|
1419
1428
|
printf '%s\n\n' "No authorization code. Starting from beginning again..."
|
|
1420
1429
|
continue
|
|
1421
1430
|
fi
|
|
1431
|
+
auth_code=$(printf "%s" "${auth_code}" | sed 's/^.*code=//;s/&.*//')
|
|
1432
|
+
printf '%s\n' "Got authorization code: ${auth_code}"
|
|
1422
1433
|
auth_response=$(curl -s -d "code=${auth_code}" -d "client_id=${client_id}" \
|
|
1423
|
-
-d "grant_type=authorization_code" -d "redirect_uri
|
|
1434
|
+
-d "grant_type=authorization_code" -d "redirect_uri=${REDIRECT_URI}" \
|
|
1424
1435
|
-d "client_secret=${client_secret}" "${OAUTH_BASE_URL}token")
|
|
1425
1436
|
auth_error=$(node -e "console.log(!!JSON.parse(process.argv[1]).error)" \
|
|
1426
1437
|
"${auth_response}")
|