1

尝试使用 curl 获取 AccessToken,但出现“https://accounts.google.com/o/oauth2/token:没有这样的文件或目录”错误有人可以帮助我做错什么吗?

主要是,我想知道我是否正确设置了客户端密码,虽然我很不确定,但我真的很感激一些指导。

(已用*编辑了某些部分)

curl \
—request POST \
--data ”code=4/***********************3Uzp--0jT4uNN******rSWSRkHw8&client_id=***************************.apps.googleusercontent.com&client_secret=**********&redirect_uri=https://localhost&grant_type=authorization_code” \https://accounts.google.com/o/oauth2/token
4

1 回答 1

0

这是我使用的代码。

# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.

# Authorization link.  Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=[Scopes]&response_type=code

# Exchange Authorization code for an access token and a refresh token.

curl \
--request POST \
--data "code=[Authentcation code from authorization link]&client_id=[Application Client Id]&client_secret=[Application Client Secret]&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code" \
https://accounts.google.com/o/oauth2/token

# Exchange a refresh token for a new access token.
curl \
--request POST \
--data 'client_id=[Application Client Id]&client_secret=[Application Client Secret]&refresh_token=[Refresh token granted by second step]&grant_type=refresh_token' \
https://accounts.google.com/o/oauth2/token

从我的一个要点 GoogleAuthenticationCurl.sh中提取的代码

于 2020-09-10T05:56:49.103 回答