【发布时间】:2016-11-11 23:22:56
【问题描述】:
我有一个基于 Java 的网络应用程序,它为给定的视频下载 youtube cmets。它在本地运行良好,但是当我将它部署到亚马逊 clound 时,由于回调 url 问题,我在身份验证过程中给出了所有错误。
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, scopes).setCredentialDataStore(datastore)
.build();
// Build the local server and bind it to port xxxxx
LocalServerReceiver localReceiver = new LocalServerReceiver.Builder().setPort( 15555 ).build();
// Authorize.
Credential credential = new AuthorizationCodeInstalledApp(flow, localReceiver).authorize("user");
);
return credential;
以上代码 sn-p 取自 youtube 开发网站。
我的问题是,因为localReciver 从 youtube 获取访问令牌,在端口 15555 上运行,所以localReceiver 无法从 youtube 获得响应,因为我的站点已打开,只能从外部访问端口 80亚马逊云..对吗?
因此,换句话说,如果我的 redirect_uri 为 redirect_uri=http://mysite.elasticbeanstalk.com:15555/Callback&response_type=code&scope=https://www.googleapis.com/auth/youtube.force-ssl
,则由于它位于端口 15555 上,因此将无法正常工作。我正试图解决这个问题以找到解决方案。你怎么做到这一点?
【问题讨论】:
标签: java youtube-api youtube-data-api google-oauth