0

I've been strugling in the past few days with an Asp.Net MVC website which has to use the Google Apis (Calendar) It works just fine in ASP.Net Developement Server, or IISExpress, but it just won't work on IIS 7.5.

Here's the basic authentication code :

private async Task Run()
{
    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
           {
               ClientId = "xxxxxxx",
               ClientSecret = "xxxxx",
           },
           new[] { CalendarService.Scope.Calendar },
           "xxx@gmail.com",
           CancellationToken.None).Result;

and on IIS I always get this :

[UnauthorizedAccessException: L'accès au chemin d'accès 'Google.Apis.Auth' est refusé.]
Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +185
Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) +114
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__1.MoveNext() in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:54

(The exception text means "Access to the path 'Google.Apis.Auth' is denied)

I had the problem with the previous version API version, upgraded to the 1.8.1.31688 version but the error remains... My app pool runs under Network Service identity, I gave it full-control access to my website folder (I even gave "Everyone" full control, just in case...) but same result.

Same symptom on my dev computer (which can be overriden using IISExpress) and the prod server, which is more "annoying"...

Thanks for any help you may bring to me !

Vincent J
  • 1
  • 1

2 Answers2

0

Is IIS running under Partial Trust? It could also possibly be trying to write to the system or ASP.NET temporary directory and failing.

Martin Costello
  • 9,672
  • 5
  • 60
  • 72
  • I added in system.web, so I guess not. I've also added full control on ASP.Net temp folder to NetworkService, not better... Thanks for the tip though – Vincent J Apr 01 '14 at 11:56
0

There is an additional parameter you can add after the cancellation token for a FileDataStore. This tells where the token should be stored. the default location is on your system in the AppData folder in your C:\ drive. Update your parameter to look like this:

...
   "xxx@gmail.com",
   CancellationToken.None,
   New FileDataStore("XXX")).Result

;

Where "XXX" is the full path on your local machine where you want it to be stored. In C#, you can use Server.MapPath to get to the root of your website, and then put the location where the token should be stored.

** NOTE: while I know this parameter is here, I STILL get this error. I added a folder to the root of my website and granted full permissions to EVERYONE but still get this error. Let me know if you are able to get around this.

Cam
  • 1
  • 3