将OAuth 2.0用于已安装的应用程序(Using OAuth 2.0 for Installed Applications)
我正在编写一个命令行工具(installedApp),需要访问用户的Google表格。 为此,我需要从用户那里获得访问令牌。
我遵循这些指南OAuth2InstalledApp 。 到目前为止,我设法通过使用redirect_uri的
http://localhost
类型获取授权代码。 我指定http://localhost:7373/authorizationCode
作为redirect_uri,我有一个本地服务器侦听端口7373。但是当我发出获取访问令牌的请求时,我得到了一个HTTP 400 Bad请求响应
redirect_uri_mismatch错误
。 当我发出请求时,redirect_uri被定义为“您从Developers Console获得的重定向URI”。 这有点不对,因为当您创建已安装的应用程序时,您无法指定重定向uri(仅限Web应用程序)。
https://infinit.io/_/i48b2rM
所以我的问题是我做错了什么?
I am programming a command line tool (installedApp) that will need access to the Google Sheets of the user. For this I need to get an access token from the user.
I am following these guidelines OAuth2InstalledApp. So far I managed to get the authorization code by using the
http://localhost
type of redirect_uri. I specifiedhttp://localhost:7373/authorizationCode
as the redirect_uri and I have a local server listening on port 7373.But when I make the request to get the access token, I get an HTTP 400 Bad request response with a
redirect_uri_mismatch error
. When I make the request,the redirect_uri is defined as "The redirect URI you obtained from the Developers Console". Which is kind of wrong because when you create an Installed app you don't have the ability to specify a redirect uri (only with web apps).
https://infinit.io/_/i48b2rM
So my question is what am I doing wrong?
原文:https://stackoverflow.com/questions/33720765
最满意答案
if sudo chmod a-x /etc/shadow 2>/dev/null then : Yes - I have root permissions else : No - I do not have root permissions or /etc/shadow does not exist or ... fi
如果成功,则选择不会造成损坏的操作(阴影密码文件不应该是可执行的;如果您愿意,可以执行
chmod ow /
- 从根目录中删除公共写入权限),并检查它是否有效通过查看命令的退出状态。 这会抛弃错误消息 - 您必须决定是否重要。'sudo'是为了提高特权; 如果你认为用户应该已经是'root',那么省略'sudo'。
if sudo chmod a-x /etc/shadow 2>/dev/null then : Yes - I have root permissions else : No - I do not have root permissions or /etc/shadow does not exist or ... fi
This chooses an operation that does no damage if it succeeds (the shadow password file is not supposed to be executable; you could do something like
chmod o-w /
- remove public write permission from the root directory if you prefer), and check that it worked by looking at the exit status of the command. This throws away the error message - you have to decide whether that matters.The 'sudo' is there to raise the privileges; if you think the user should already be 'root', then omit the 'sudo'.
相关问答
更多-
您可以使用另一个grep来查看paste的输出是否包含以下内容: read -r var rest < <( \ cat data.txt \ | grep foo \ | paste -s -d' ' \ | grep . \ || die "PIPELINE" \ ) || die "OUTER" In the end I went with two different solutions depending on the context. The first ...
-
在bash中检测虚拟化(Detect virtualization in bash)[2019-11-13]
有一个非常有用的脚本叫做imvirt ,它可以处理Xen,OpenVZ,VMware,VirtualBox,KVM等等。 它可以作为Debian中的软件包提供,也可以从imvirt网站获得 。 $ imvirt Xen PV 4.1 I found a small shell script that is able to detect virtualization and it handles Xen,OpenVZ,KVM,Parallels, Vmware and many more virt-what ... -
var=`svn ls` if [[ $? == 0 ]] then export var else unset var fi $? 是执行的最后一个命令的退出代码,在这里是svn ls 。 jmohr的解决方案简短而甜蜜。 适应温和, var=`svn ls` && export var || unset var 将近似等于上面的情况(除非你做了一些可怕的事情并且用完了环境空间,否则export一个有效的标识符永远不会失败)。 采取任何你想要的 - 我使用unset只是 ...
-
如何从docker中检测bash中完全交互的shell?(How to detect fully interactive shell in bash from docker?)[2022-01-17]
entrypoint.sh: #!/bin/bash set -e if [ -t 0 ] ; then echo "(interactive shell)" else echo "(not interactive shell)" fi /bin/bash -c "$@" Dockerfile: FROM debian:7.8 COPY entrypoint.sh /usr/bin/entrypoint.sh RUN chmod 755 /usr/bin/entrypoint.sh ... -
也许考虑不依赖于环境变量? 如果您不反对分发解压缩的文件集,则可以轻松使用LoadLocationFromTZData(name string, data []byte) 。 第二个参数是单个时区文件的内容。 作为参考,处理zip文件的功能可在未导出的函数loadTzinfoFromZip() 。 从@ Slotherooo的评论中提取的逐步方法: 制作本地版本的time.loadTzinfoFromZip(zipfile, name string) ([]byte, error) 使用该方法从timein ...
-
在这种情况下,您要检查参数是否未设置。 has_1() { if [[ -z "${1+present}" ]]; then echo "no first param" else echo "given: $1" fi } 仅当参数未设置时 , 参数扩展 ${var+word}才会返回“word” - 即如果传递空字符串,则函数将指示给出第一个参数。 In this case, you want to check if the parameter is unset. has_ ...
-
如何在bash中“尝试做某事然后检测它是否失败”?(How can I “try to do something and then detect if it fails” in bash?)[2021-11-17]
if sudo chmod a-x /etc/shadow 2>/dev/null then : Yes - I have root permissions else : No - I do not have root permissions or /etc/shadow does not exist or ... fi 如果成功,则选择不会造成损坏的操作(阴影密码文件不应该是可执行的;如果您愿意,可以执行chmod ow / - 从根目录中删除公共写入权限),并检查它是否有效通过查看命令的退出状态。 这 ... -
这样的事情适用于你的第一个问题: list=$(ls -l1) echo "ls output: $list" echo命令将一直等到$(和)内的命令完成。 对于第二个问题,更好的方法是(如果你有sudo权限): sudo su -c 'echo "hi from $(whoami)"' echo "hi from $(whoami)" Does something like this works for your first question: list=$(ls -l1) echo "ls outp ...
-
你应该期待你的提示。 说你的提示是“s”,你的代码应该是: bash.expect(">") 甚至首先为你的提示设置一个变量(如果以后你想改变你的提示;)) prompt = ">" bash.expect(prompt) You should expect your prompt. Say your prompt is "s", your code should be : bash.expect(">") or even set a variable first for your prompt (i ...
-
如何在bash脚本中检测父会话已完成?(How to detect in a bash script that the parent session has finished ?)[2021-02-22]
通常,当会话关闭时,SIGHUP将被发送到进程。 在Bash中,您可以使用trap命令来检测信号。 例如,如果您事先执行trap exit SIGHUP ,那么Bash将在收到SIGHUP时退出。 Usually, when a session is closed, SIGHUP will be sent to the processes. In Bash, you can use trap command to detect signals. For example, if you execute tra ...