Ik heb de volgende code:
Telkens krijg ik de volgende foutmelding:
Iemand ervaring met Google.Apis en Service Accounts (=public api ipv. OAuth Client tokens), die me op de juiste weg kan zetten? (permissies, scope en dergelijke lijken te kloppen, klok gesyncroniseerd met een NTP server)
Volgende documentatie had ik gevonden:
C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| string key = @"1ae295acc7cxxxxxx-privatekey.p12"; private ServiceAccountCredential getCredential() { String serviceAccountEmail = "drive-xxx-xxx@appspot.gserviceaccount.com"; byte[] file = System.IO.File.ReadAllBytes(key); var certificate = new X509Certificate2(file, "notasecret", X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { DriveService.Scope.Drive } }.FromCertificate(certificate)); return credential; } public async Task<List<string>> getFileNames(string file_id = "0BwqjmHstKb9xQVM5Nzk5aV9jNGc") { var service = new DriveService(new BaseClientService.Initializer { HttpClientInitializer = getCredential(), ApplicationName = "Drive-CMS" //,ApiKey = "AIzaSyCINts_9MUxxxxkiKykvpPFUs" }); //var t = service.Files.Get(file_id).Execute();//error var list = await service.Files.List().ExecuteAsync(); //error! (zelfde) return list.Items.Select(dl => dl.Title).ToList(); } |
Telkens krijg ik de volgende foutmelding:
code:
1
| [TokenResponseException: Error:"invalid_grant", Description:"", Uri:""] |
Iemand ervaring met Google.Apis en Service Accounts (=public api ipv. OAuth Client tokens), die me op de juiste weg kan zetten? (permissies, scope en dergelijke lijken te kloppen, klok gesyncroniseerd met een NTP server)
Volgende documentatie had ik gevonden:
- YouTube: Google Drive SDK: Service accounts
- https://developers.google...te_a_drive_service_object (dotnet open aoth)
- https://developers.google...aaa_oauth#service_account (auth met Plus.Me account - hierop gebaseerd)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| Serverfout in toepassing /. Error:"invalid_grant", Description:"", Uri:"" Beschrijving: Er is een onverwerkte uitzondering opgetreden tijdens het uitvoeren van de huidige webaanvraag. Raadpleeg de stacktracering voor meer informatie over deze fout en de oorsprong ervan in de code. Details van uitzondering: Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"invalid_grant", Description:"", Uri:"" Fout in bron: Regel 46: //string url = t.DownloadUrl; Regel 47: Regel 48: var list = await service.Files.List().ExecuteAsync(); Regel 49: //var list = service.Files.List().Execute(); Regel 50: return list.Items.Select(dl => dl.Title).ToList(); Bronbestand: c:\Users\Nico\Documents\Visual Studio 2013\Projects\Sapico-Nuget\Sapico.CMS.Drive\Connector.cs Regel: 48 Stacktracering: [TokenResponseException: Error:"invalid_grant", Description:"", Uri:""] Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +193 Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) +100 Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +50 Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaiter.GetResult() +41 Google.Apis.Requests.<ExecuteAsync>d__0.MoveNext() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis\Apis\Requests\ClientServiceRequest.cs:126 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 Sapico.CMS.Drive.<getFileNames>d__3.MoveNext() in c:\Users\Nico\Documents\Visual Studio 2013\Projects\Sapico-Nuget\Sapico.CMS.Drive\Connector.cs:48 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 Drive.CMS.WebTest.Controllers.<Index>d__0.MoveNext() in c:\Users\Nico\Documents\Visual Studio 2013\Projects\Sapico-Nuget\Drive.CMS.WebTest\Controllers\HomeController.cs:17 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +61 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +114 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +66 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +135 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +117 System.Web.Mvc.Async.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() +323 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +44 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +135 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +72 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +132 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +138 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +138 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +138 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38 System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129 Versiegegevens: Microsoft .NET Framework Versie:4.0.30319; ASP.NET Versie:4.0.30319.34009 |
[ Voor 62% gewijzigd door NicoJuicy op 30-04-2014 23:55 ]