谷歌应用程序脚本卷曲授权 [英] Google App Scripts curl authorization

查看:153
本文介绍了谷歌应用程序脚本卷曲授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想与谷歌应用程序的脚本玩。在匿名模式下事情似乎罚款。但任何人都可以打电话给我的剧本只是这样的片段显示:

 卷曲的https://script.google.com/macros/s/.../exec IP = \\$ MYIP \\

我用 本手册 的提示如何通过的GoogleLogin验证。现在的问题是401未授权发送身份验证令牌和我(车主)/只有我自己选项都设置在谷歌方面当我收到。 (令牌似乎是正确的本身。如果我省略密码,或输错了,那么我收到坏AUTH)如果设置了任何人,甚至匿名再次,它的工作原理,但权威性的东西好像忽略。什么是应该做的伎俩正确的方法是什么?

 #!/斌/庆典
Gmail的= $ 1
密码= $ 16
MYIP = $ 3
GoogleAuthToken =
GoogleAuthToken =`卷曲--silent https://www.google.com/accounts/ClientLogin --data-urlen code电子邮件= $ Gmail的\\
--data-urlen code的passwd = $密码-d ACCOUNTTYPE = GOOGLE -d源= YouDontSay -d服务= lh2`
回声$ GoogleAuthToken
GoogleAuthToken = $(回声$ GoogleAuthToken| grep'可以验证='| sed的S /验证= //)
回声$ GoogleAuthToken
卷曲-L --silent --header授权:AUTH的GoogleLogin = $ GoogleAuthTokenHTTPS://script.google.com/macros/s/.../exec IP = \\$ MYIP \\


解决方案

您使用ClientLogin

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

这是谷歌的错误:


  

重要提示:ClientLogin的已自4月20日正式pcated德$ P $,
  2012年和现在不再可用。请求给ClientLogin会失败
  用HTTP 404响应。我们建议您迁移至OAuth 2.0作为
  尽快


Just trying to play with google app scripts. In anonymous mode things seem fine. Except that anyone can call my script simply like that snippet shows:

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

I used this manual for tips on how to authenticate through GoogleLogin. The problem is "401 Unauthorized" I received when sent auth token and "Me(owner)/Only myself" options were set on google side. (The token seems correct itself. If I omit password or mistype it, then I receive "Bad auth") If I set "Anyone, even anonymous" again, it works, but auth stuff seems like 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\""

解决方案

You use ClientLogin

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

This is google error :

Important: ClientLogin has been officially deprecated since April 20, 2012 and is now no longer available. Requests to ClientLogin will fail with a HTTP 404 response. We encourage you to migrate to OAuth 2.0 as soon as possible.

这篇关于谷歌应用程序脚本卷曲授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆