I am trying to deploy an ASP.NET application the Windows Azure cloud. I am using Google API for one of the calls in the application. When I do this, I get the following error:
System.UnauthorizedAccessException: Access to the path 'Google.Apis.Auth' is denied.`
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.`
To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.`
I tried researching this, but all the suggestions talk about changing the IIS server settings, which I don't believe I have access to since this is running in the cloud. Can anyone help?
EDIT: here is the code for the function that's giving the error:
Async Function SpecialTest() As Task(Of String)
Dim credential As UserCredential
Dim clientSecretsPath As String = Server.MapPath("~/App_Data/client_secret.json")
Dim scopes As IList(Of String) = New List(Of String)()
scopes.Add(CalendarService.Scope.Calendar)
Dim stream As FileStream = New FileStream(clientSecretsPath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Using stream
credential = Await GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.Load(stream).Secrets, scopes, "user3", CancellationToken.None)
End Using
Dim baseInitializer = New BaseClientService.Initializer()
With baseInitializer
.HttpClientInitializer = credential
.ApplicationName = "P1"
End With
Dim service = New CalendarService(baseInitializer)
Dim Calendars = (Await service.CalendarList.List().ExecuteAsync()).Items()
Dim toReturn As String = "{""items"": ["
For Each firstCalendar As CalendarListEntry In Calendars
If firstCalendar IsNot Nothing Then
' Get all events from the first calendar.
Dim calEvents = Await service.Events.List(firstCalendar.Id).ExecuteAsync()
' DO SOMETHING
Dim items = calEvents.Items
'Return JsonConvert.SerializeObject(calEvents)
For Each ite As Google.Apis.Calendar.v3.Data.Event In items
If Not (ite.Location Is Nothing) And Not (ite.Start Is Nothing) Then
Dim tst = ite.Start.DateTime
toReturn = toReturn + " [""" + Date.Parse(ite.Start.DateTime).ToShortDateString + """" + "," + """" + ite.Location + """" + "," + """" + ite.Start.DateTime + """" + "," + """" + ite.Start.DateTime + """" + "," + """""],"
End If
Next
End If
Next
toReturn = toReturn.Substring(0, toReturn.Length - 1)
Return toReturn + "]}"
End Function`
Try this.
A.If you have RDP Acces to the Azure cloud then change the IIS settings
B.I think you are using any local path. You should change this to local storage for temporary requirement and blob storage for long requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With