Google App Scripts authorization authorization

Just try playing with google app scripts. Everything looks fine in anonymous mode. Except that anyone can call my script just like this snippet shows:

curl "https://script.google.com/macros/s/.../exec?ip=\"$myIp\""

      

I used this tutorial to find out how to authenticate with GoogleLogin. The problem is that the "401 unauthorized" I got when the authentication token was sent and the "I (owner) / Myself only" options were set on google side. (The token itself seems to be correct. If I omit the password or am wrong, I get "Bad auth"). If I set "Anyone, even anonymous" again, it works, but the auth file seems to be ignored. What's the correct way to do the trick?

#!/bin/bash
gmail=$1
password=$2
myIp=$3
GoogleAuthToken=""
GoogleAuthToken=`curl --silent https://www.google.com/accounts/ClientLogin --data-urlencode Email=$gmail \
--data-urlencode Passwd=$password -d accountType=GOOGLE -d source=YouDontSay -d service=lh2`
echo $GoogleAuthToken
GoogleAuthToken=$(echo "$GoogleAuthToken" | grep 'Auth=' | sed  s/Auth=//)
echo $GoogleAuthToken 
curl -L --silent --header "Authorization: GoogleLogin auth=$GoogleAuthToken" "https://script.google.com/macros/s/.../exec?ip=\"$myIp\""

      

+3


source to share


1 answer


You are using ClientLogin

https://www.google.com/accounts/ClientLogin

      



This is google bug:

Important: ClientLogin has been officially deprecated since April 20th, 2012 and is no longer available. ClientLogin requests will fail with an HTTP 404 response. We recommend that you upgrade to OAuth 2.0 as soon as possible.

0


source







All Articles