我想從Windows Phone應用程序添加一個時刻兩天,現在我無法得到它的工作。沒有真正的教程或從未做過的事情......無論如何,從各種各樣的資源中,我可以登錄,請求範圍(即使login.plus範圍由於某種原因未被請求),我嘗試張貼片刻。這是我能夠創建的代碼插入時刻谷歌加google-api-dotnet客戶端WP8錯誤401
List<string> scopes = new List<string>();
scopes.Add("https://www.googleapis.com/auth/plus.login");
scopes.Add("https://www.googleapis.com/auth/userinfo.email");
var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = "<My client ID>",
ClientSecret = "<My Client Secret>"
},
scopes,
"user",
CancellationToken.None);
var initializer = new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "WP Drive Sample Application",
};
var plusService = new PlusService(initializer);
Moment body = new Moment();
ItemScope target = new ItemScope();
target.Id = "<Unique ID>";
target.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
target.Type = "";
target.Description = "The description for the activity";
target.Name = "An example of add activity";
body.Target = target;
body.Type = "http://schemas.google.com/AddActivity";
MomentsResource.InsertRequest insert =
new MomentsResource.InsertRequest(
plusService,
body,
"me",
MomentsResource.InsertRequest.CollectionEnum.Vault);
Moment wrote = await insert.ExecuteAsync();
當我嘗試使用insert.ExecuteAsync()時出現此錯誤;
{The service plus has thrown an exception: Google.GoogleApiException: Google.Apis.Requests.RequestError
Unauthorized [401]
Errors [
Message[Unauthorized] Location[ - ] Reason[unauthorized] Domain[global]
]
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Google.Apis.Requests.ClientServiceRequest`1.<ExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at GooglePlus.MainPage.<Test>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__0(Object state)}
經過一番搜索後,我發現可能是爲什麼我無法訪問它的問題是我沒有使用request_visible_actions。但問題是,我不知道如何用我的代碼請求它,我在c sharp上找不到任何資源,我可以在我的windows phone應用程序中使用它。任何想法如何解決這個問題,並能夠從我的應用程序最後張貼一段時間?
您是否檢查出該鏈接:http:// ikaisays。COM/2013/07/19 /調試,你 - 谷歌 - OAuth的2-0-令牌時任您得到-HTTP-401S-OR-403S /。在我看來,你沒有啓用API。 – peleyal
我已啓用Google+ API –
你有效嗎? – DaImTo