@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.
@@ -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=urn:ietf:wg:oauth:2.0:oob"
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: if the OAuth client is not for a native application, there will be an \
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 from browser and paste here: "
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=urn:ietf:wg:oauth:2.0:oob" \
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}")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google-cloud/nodejs-common",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A NodeJs common library for solutions based on Cloud Functions",
5
5
  "author": "Google Inc.",
6
6
  "license": "Apache-2.0",