Youtube oauth2没有web服务-urn:ietf:wg:oauth:2.0:oob



所以我在谷歌云上创建了youtubeapi项目。我测试了通过urn:ietf:wg:oauth:2.0:oob重定向uri获取身份验证代码,我不想让webservice对我的帐户进行身份验证。一切都很好,因为我在浏览器中获取代码,但我在将此身份验证代码发布到api时遇到了问题。当我试图通过RestMan(类似于邮递员(发布身份验证码时,它向我显示:

<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 404 (Not Found)!!1</title>
<style nonce="CIsxxpEHaaEHNiQiddzf7Q">
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{color:#222;text-align:unset;margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px;}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}pre{white-space:pre-wrap;}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<main id="af-error-container" role="main"><a href=//www.google.com><span id=logo aria-label=Google role=img></span></a>
<p><b>404.</b> <ins>That’s an error.</ins>
<p>The requested URL was not found on this server. <ins>That’s all we know.</ins>
</main>

我在RestMan:中的数据

网址:https://accounts.google.com/o/oauth2/token/

原料:code=MYCODE&client_id=MYCLIENTID&client_secret=MYSECRET&redirect_uri=urn:ietf:wg:oauth:2.0:oob&grant_type=authorization_code

我认为这可能是redirect_uri部分的body的问题。有人能告诉我应该在那里写什么吗?需要使用localhost创建Web服务授权吗?

编辑:好的,我刚刚使用了java的youtube客户端库。示例代码非常有用,连接应该是安全的。链接:https://developers.google.com/api-client-library/java/

a(您可能使用了错误的URL。使用谷歌发现文档:https://accounts.google.com/.well-known/openid-configuration查找令牌端点:

"token_endpoint":"https://oauth2.googleapis.com/token",

b( 考虑设置localhost以获取授权代码和刷新令牌。看见https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html.

好的,我刚刚使用了java的youtube客户端库。示例代码非常有用,连接应该是安全的。链接:https://developers.google.com/api-client-library/java/

最新更新