【问题标题】:GoogleOAuth redirect URL, LocalServerReceiver port numberGoogleOAuth 重定向 URL、LocalServerReceiver 端口号
【发布时间】: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


    【解决方案1】:

    我找到了一个解决方法: 我在本地进行了身份验证,生成了令牌并将文件复制到服务器,它可以工作,但不确定刷新过程是否会工作。

    【讨论】:

      【解决方案2】:

      您是否尝试过使用 setHost?

      new LocalServerReceiver.Builder().setHost("myelasticbeanch.com").setPort(15555).build();
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-06-08
        • 2017-01-06
        • 2020-03-18
        • 1970-01-01
        • 2012-11-11
        • 2011-03-22
        • 2017-09-09
        • 2015-03-15
        相关资源
        最近更新 更多