连接到Google Sheets API使用本地主机

2024-04-18 17:06:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的是Django。我正在尝试使用googlesheetsapi。好吧,我现在正在一个本地环境中工作,google接受OAuth需要给定一个特定的域,而localhost不工作,所以我使用ngrok。所以我用ngrok给我的域名和URL填充了所有的字段。 我还使用了我的ngrok URL来填充那些凭证字段。我已经下载了client_secret.json文件,并按照google在他们的表单API文档中的建议设置了所有连接和内容。你知道吗

但当我访问我的ngrok网址和google连接时,我仍然看到这样一条我无法摆脱的信息:

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=...&redirect_uri=http%3A%2F%2Flocalhost%3A35701%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fspreadsheets&state=...&access_type=offline

该链接下的消息是:

Error: redirect_uri_mismatch
The redirect URI in the request, http://localhost:39515/, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: link to my profile

但是在我的client_secretredirect_uris被设置为:

"redirect_uris":["http://something.ngrok.io/plan/create"]

现在我完全不知道发生了什么事。你知道吗


Tags: thedjangoclientlocalhosthttpurlsecrettype