locked
oauth authentication RRS feed

  • Question

  • User1119553929 posted

    i have this code:

    string[] scopes = new string[] { "https://www.googleapis.com/auth/contacts" }; // view your basic profile info.

    // Use the current Google .net client library to get the Oauth2 stuff.
    UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
    , scopes
    , "teste"
    , CancellationToken.None
    , new FileDataStore(Server.MapPath("/") + "Datastore")).Result;

    // Translate the Oauth permissions to something the old client libray can read
    OAuth2Parameters parameters = new OAuth2Parameters();
    parameters.AccessToken = credential.Token.AccessToken;
    parameters.RefreshToken = credential.Token.RefreshToken;


    RequestSettings settings = new RequestSettings("contacts-241813", parameters);
    ContactsRequest cr = new ContactsRequest(settings);

    if(User.Identity.IsAuthenticated)

    CreateContact(cr);

    ---------------------------------------------

    locally runs fine

    when i deploy to IIS or hosting iis i get this error:

    Line 92:             
    Line 93:                 // Use the current Google .net client library to get the Oauth2 stuff.
    Line 94:                 UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
    Line 95:                                                                                              , scopes
    Line 96:                                                                                              , "teste"


    Source File: C:\Users\Nando\Desktop\Contacts\Contacts\Controllers\HomeController.cs    Line: 94 

    Stack Trace: 

    [Win32Exception (0x80004005): Access is denied]
       System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) +604
       System.Diagnostics.Process.Start(ProcessStartInfo startInfo) +60
       Google.Apis.Auth.OAuth2.<ReceiveCodeAsync>d__16.MoveNext() +258
    
    [NotSupportedException: Failed to launch browser with "https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&response_type=code&client_id=23969819486-75cvofc052k333h0sc3pee549slvr87k.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A64517%2Fauthorize%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcontacts" for authorization. See inner exception for details.]
       Google.Apis.Auth.OAuth2.<ReceiveCodeAsync>d__16.MoveNext() +832
       System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
       System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
       Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__8.MoveNext() +701
       System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
       System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
       Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__4.MoveNext() +572
       System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31
       System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +60
       Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__1.MoveNext() +426


    i granted permission to folder Datastore in Server.Mappath

    What can i do ?


    Sunday, May 26, 2019 6:06 PM

All replies