谷歌联系API - 401目标无效 [英] Google Contact API - 401 Target Invalid

查看:299
本文介绍了谷歌联系API - 401目标无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目是使用与Gmail的OAuth PHP和面临这个错误401无效的目标所在的其他项目中使用相同的方式(不同的ID和密钥,但同一域)工作正常。对于前: -

my project is using php with gmail oauth and facing this error as 401 Target Invalid where the other project works fine using the same way (different ID and Secret but same domain). For ex:-

xxx.com/abc
xxx.com/def

xxx.com/abc xxx.com/def

HTTP/1.1 401 Token invalid - Target is invalid.
Content-Type: text/html; charset=utf-8
Date: Mon, 19 May 2014 02:03:50 GMT
Expires: Mon, 19 May 2014 02:03:50 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alternate-Protocol: 443:quic
Transfer-Encoding: chunked

我怎样才能解决这个问题?鸭preciate任何意见和帮助。

How can I resolve this issue? Appreciate with any comments and helps.

GmailOath codeS

 $url = 'https://www.google.com/accounts/OAuthGetRequestToken';
 $params['oauth_version'] = '1.0';
 $params['oauth_nonce'] = mt_rand();
 $params['oauth_timestamp'] = time();
 $params['oauth_consumer_key'] = $oauth->oauth_consumer_key;
 $params['oauth_callback'] = $oauth->callback;
 $params['scope'] = 'https://www.google.com/m8/feeds';

更新:
我猜这可能是问题。下面不同的将是内容类型,它应该是应用/ JSON的。但不知道从哪里变他们...

Update: I'm guessing this might be the issue. Below different would be the Content-type where it should be 'application/json'. But have no idea where to change them...

更新:
经过进一步调查,它会工作后,才取代了旧的应用程序的客户端ID和秘密在 https://开头控制台.developers.google.com / 不管有多少新的应用程序,我尝试生成密钥,它只是不工作。这是怎么回事?

Update: After further investigation, it will works only after I replaced the Client ID and Secret of an old application at https://console.developers.google.com/ No matter how many new apps that I try to generate the keys, it just don't work. What's happening?

工作电话: -

[url] => https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=1000&oauth_consumer_key=59093836836-0c8mb4u395gklok3k52cr2b0oml3gmcg.apps.googleusercontent.com&oauth_nonce=1103659829&oauth_signature=ORgJZEli8Y0b1Bv1xUwFWysdJgA%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1400465100&oauth_token=1%2FL0o-ttvJP0haJ2RF9I-jd6hOIW2-kFYiQmlNx7UWVkw&oauth_version=1.0
            [content_type] => application/json; charset=UTF-8
            [http_code] => 200
            [header_size] => 525
            [request_size] => 743
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 2.250314
            [namelookup_time] => 4.7E-5
            [connect_time] => 0.012625
            [pretransfer_time] => 0.040877
            [size_upload] => 0
            [size_download] => 997382
            [speed_download] => 443219
            [speed_upload] => 0
            [download_content_length] => -1
            [upload_content_length] => 0
            [starttransfer_time] => 0.423671
            [redirect_time] => 0

不工作电话: -

Not working call :-

 [url] => https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=1000&oauth_consumer_key=59093836836-57psirebb7ntghd1259g4iiml5eq0l70.apps.googleusercontent.com&oauth_nonce=995553446&oauth_signature=8yPK5su1np6sC0z8vmZ%2BHOW7CuE%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1400465030&oauth_token=1%2FrDfOd04W2oUs2MHfLoFIJoVngnM0n3MWZwWMRoeFDOg&oauth_version=1.0
                [content_type] => text/html; charset=utf-8
                [http_code] => 401
                [header_size] => 369
                [request_size] => 745
                [filetime] => -1
                [ssl_verify_result] => 0
                [redirect_count] => 0
                [total_time] => 0.337964
                [namelookup_time] => 4.7E-5
                [connect_time] => 0.017053
                [pretransfer_time] => 0.054309
                [size_upload] => 0
                [size_download] => 11875
                [speed_download] => 35136
                [speed_upload] => 0
                [download_content_length] => -1
                [upload_content_length] => 0
                [starttransfer_time] => 0.337551
                [redirect_time] => 0

请不要索取详细信息,如果上面的问题是不完整的。谢谢你。

Please do ask for more information if above questions is not complete. Thanks.

推荐答案

找出了解决办法,

看起来像新生成的客户端ID和客户端密钥已经淘汰了的旧版本的API。使这部作品的唯一途径是通过实施谷歌联系APIv3和使用的OAuth2。

Looks like the newly generated Client ID and Client Secret have already phased out for older version of API. The only way to make this works is by implementing Google Contact APIv3 and using OAuth2.

希望这有助于其他具有相同的问题谁。

Hope this help the rest who having the same issues.

这篇关于谷歌联系API - 401目标无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆