Access to the path 'C:\Windows\system32\config\systemprofile' is denied when using Google.Api OAuth 2

Viewed 11647

I am using Google Calendar Api with one of my project. I don't know how but Error Shown Below is troubling.

Here is the Error

Stack Trace of Error

Code inside AppFlowMetadata.

public class AppFlowMetadata : FlowMetadata
{
    private static readonly IAuthorizationCodeFlow flow =
        new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
        {
            ClientSecrets = new ClientSecrets
            {
                ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
                ClientSecret = "xxxxx_xxxxxxxxxxxxxxxxx"
            },
            Scopes = new[] { CalendarService.Scope.Calendar },
            DataStore = new FileDataStore("Calendar.Api.Auth.Store")
        });

    public override string GetUserId(Controller controller)
    {
        var user = controller.Session["UserID"];

        if (user == null)
        {
            user = Guid.NewGuid();
            controller.Session["UserID"] = user;
        }
        return user.ToString();

    }

    public override IAuthorizationCodeFlow Flow
    {
        get { return flow; }
    }
}

I tried below solution from GitHub but isn't working

I tried this Solution

Above solution didn't worked for me, if any have the answer please help.

4 Answers

I don't think you give permission to this folder C:\Windows\system32\config\systemprofile. Try using absolute path like this image or convert a relative path to absolute (by using server map path).

Make sure you have enough permission on this folder.

enter image description here

Related