Skip to content

Commit

Permalink
Update migration-script-ubuntu.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
JayanaGunaweera01 authored Jun 28, 2023
1 parent fb1b367 commit ccbe7b4
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@ echo "${GREEN}==> Navigated to home folder successfully${RESET}"
access_token=$(curl -d "client_id=$gcpClientId&client_secret=$gcpClientSecret&refresh_token=$gcpRefreshToken&grant_type=refresh_token" \
-H "Content-Type: application/x-www-form-urlencoded" \
https://oauth2.googleapis.com/token | jq -r '.access_token')

echo "$access_token"
# Check if the response contains any error message
if echo "$access_token" | grep -q '"error":'; then
# If there is an error, print the failure message with the error description
error_description=$(echo "$access_token" | jq -r '.error_description')
echo -e "${RED}${BOLD}Failure in generating an access token $error_description${NC}"

else
# If there is no error, print the success message
echo -e "${PURPLE}${BOLD}Success: An access token generated successfully .${NC}"
echo -e "${PURPLE}${BOLD}Success: An access token generated successfully.${NC}"
# Save the access token to a file called "access_token"
echo "$access_token" > access_token
fi

# Specify the Google Drive file URL
Expand All @@ -111,8 +112,9 @@ file_url="$urlOld"
# Extract the file ID from the URL
file_id=$(echo "$file_url" | awk -F'/' '{print $NF}' | awk -F'=' '{print $2}')

# Download the file using the access token
response=$(curl "https://www.googleapis.com/drive/v3/files/1pePZJM0gIFlPft8qSsu4613kiVzuLQHs?alt=media" \
# Download the file using the access token from the "access_token" file
access_token=$(cat access_token)
response=$(curl "https://www.googleapis.com/drive/v3/files/$file_id?alt=media" \
--header "Authorization: Bearer $access_token" \
--header "Accept: application/json" \
--compressed -O wso2is.zip)
Expand Down

0 comments on commit ccbe7b4

Please sign in to comment.