无法获取Google云端硬盘的访问令牌和刷新令牌

时间:2015-04-17 19:06:35

标签: java google-drive-api google-oauth google-oauth2

我开发了一个Java Web应用程序,用于将google驱动器与我们的平台集成。从今天早上开始,我看到一个奇怪的问题,同时打电话获取访问令牌和刷新令牌,我开始得到

错误:

  

HTTP / 1.1 500内部服务器错误[Vary:X-Origin,Content-Type:application / json; charset = UTF-8,日期:星期五,2015年4月17日18:06:25 GMT,到期日:2015年4月17日星期五18:06:25 GMT,Cache-Control:private,max-age = 0,X-Content-类型选项:nosniff,X-Frame-Options:SAMEORIGIN,X-XSS-Protection:1; mode = block,Server:GSE,Alternate-Protocol:443:quic,p = 1,Accept-Ranges:none,Vary:Origin,Accept-Encoding,Transfer-Encoding:chunked]

我什么时候打电话来获取访问权限或刷新令牌

目前我正在关注this documentation我正在使用 “https://www.googleapis.com/oauth2/v3/token”要获取访问权限,这个应用程序已经开发了很长一段时间,直到昨天我工作正常,没有任何问题,

        HttpPost httpPost = new HttpPost(config.getAccessTokenUrl());
        httpPost.setHeader("Authorization", "Basic ");

        List<NameValuePair> parameters = new ArrayList<NameValuePair>();
        parameters.add(new BasicNameValuePair("code", authCode));
        parameters.add(new BasicNameValuePair("client_id", config.getClientId()));
        parameters.add(new BasicNameValuePair("client_secret", config.getClientSecuret()));
        parameters.add(new BasicNameValuePair("redirect_uri", config.getRedirectUrI()));
        parameters.add(new BasicNameValuePair("grant_type", "authorization_code"));

        UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters);
        httpPost.setEntity(sendentity);

        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(httpPost);

        if (response != null && response.getEntity() != null) {

这是我用来获取访问令牌并使用下面的代码获取刷新令牌的代码。

        HttpPost httpPost = new HttpPost(config.getAccessTokenUrl());
        httpPost.setHeader("Authorization", "Basic");

        List<NameValuePair> parameters = new ArrayList<NameValuePair>();
        parameters.add(new BasicNameValuePair("refresh_token", refreshToken));
        parameters.add(new BasicNameValuePair("client_id", config.getClientId()));
        parameters.add(new BasicNameValuePair("client_secret", config.getClientSecuret()));
        parameters.add(new BasicNameValuePair("grant_type", "refresh_token"));

        UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters);
        httpPost.setEntity(sendentity);

        HttpClient client = new DefaultHttpClient();
        HttpResponse response = client.execute(httpPost);

        if (response != null && response.getEntity() != null) {

如何尽快解决此问题,它正在制作中

0 个答案:

没有答案