struggling to authenticate在Google+ API後,我終於成功找回我的信息與https://www.googleapis.com/plus/v1/people/ {MyUserId}?關鍵= {ApiKey}Google+的API讓人們「我」
然而,儘管我沒有獲得與訪問令牌範圍https://www.googleapis.com/auth/plus.me我不能請求「我」:https://www.googleapis.com/plus/v1/people/me?key= {ApiKey}
我最終得到401未經授權的請求......這是遲到了,我沒有得到我想念的東西。
這裏是我的代碼:
string apiUrl = "https://www.googleapis.com/plus/v1/people/me?key={my api key";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
request.Method = HttpMethod.GET.ToString();
try
{
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
=> 401 error
謝謝您的幫助!
嘗試排除API密鑰,一旦您獲得了OAuth令牌 - [People:get](http://developers.google.com/+/api/latest/people/get#examples) _:「」如果使用userId值「me」,則此方法需要使用已授予OAuth範圍的令牌進行認證「」._ [OAuth](http://developers.google.com/+/api/oauth ):_「」如果請求需要授權(例如對個人私人數據的請求),則它必須包含OAuth 2.0令牌。它也可能包含API密鑰,但它不一定要。「」_ – Smudge202
您需要像這樣請求:'「https://www.googleapis.com/plus/v1/people/me?key={api key}&access_token = {access token}「' –