-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem authenticating to Blogger using Oauth2 and GoogleWebAuthorizationBroker.AuthorizeAsync #907
Comments
I suspect the exception details would be useful here - you've shown us the stack trace, but not the exception, unless that's what you mean by "the directory name is invalid". (What's the exception type? Any more detail about which directory it's looking at?) |
Try this https://github.com/LindaLawton/Google-Dotnet-Samples/blob/Genreated-samples1.0/Blogger API/v3/Oauth2Authentication.cs |
Ok i will check it in the morning. |
While digging a little I think I found the problem, but the fix will require a new release of Google API DLLs. My error is thrown in Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.cs line 82 when a Process.Start() is called and a "The directory name is invalid" error is generated. While looking at the LocalServerCodeReceiver.cs code, line 82 (https://github.com/google/google-api-dotnet-client/blob/master/Src/Support/GoogleApis.Auth.DotNet4/OAuth2/LocalServerCodeReceiver.cs), I found the method ReceiveCodeAsync() and the Process.Start(authorizationUrl); at line 86 which I think is generating the problem. I'm wondering why the Google API tries to "Open a browser with authorizationUrl URL" at that line of code ? I don't know, but... opening a browser URL with Process.Start() could generate problems on some machines, as I found here: http://stackoverflow.com/questions/7693429/process-start-to-open-an-url-getting-an-exception There are few options to fix this: 2 - If the scope will let you, use a WebClient or another class to make a web request to that URL Please let me know when a new release is available for Google.Apis.Auth.OAuth2 nuget |
I cant recreate this. I created two separate console applications .net 4.6.1 and .net 4.0 both work fine i am not seeing your problem. Note: We don't support .net 3.5 so its not going to work and we don't completely support .net 4.0 any more either. so make sure you are using at least .net 4.5 We need to prompt the user for authenticating using the auth uri. Personally i think start process
Is IMO a bad idea considering that Mircorsoft is moving away from IE to edge and I for one would rather spawn the users default browser then force them to use a browser they don't prefer. Can i get some information on your system and what user you are currently running as it almost sounds like you cant access |
I'm using Windows 10 and .NET 4.5. My problem was that my system wouldn't start the Default Browser when Process.Start("URL") is called because somehow Edge was deactivated. When I tried to manually set the default browser from Edge to Chrome in the Default Apps interface it didn't worked. I found a way to reinstall Edge and now the Google API DLL is working, Edge was showing and I was able to allow access to Blogger for my app. I still think the Process.Start(URL) from LocalServerCodeReceiver should take into consideration if no (default) browser is present in the system and throw the appropiate exception. A "try { Process.Start(URL); } catch { throw new Exception("Default browser could not be found" }" should do it. |
I think the instance of a user not having a default browser selected is pretty low. That being said I am all for notifying users of potential issues with nice messages. You are welcome to submit a pull request if you want to fix it since your the one who found it :) |
Log error, and provide a moer helpful exception message Updates googleapis#907
Log error, and provide a moer helpful exception message Updates #907
We definitely want to maintain the current behaviour of using the default browser. |
I've tried many things, tried to authenticate to Blogger using many samples from the web, tried with SharpDevelop, tried with Visual Studio 2015, tried with .NET 3.5, tried with .NET 4.5.2 and I get the same error every time coming from mscorlib "The directory name is invalid".
It looks like something from Google API, class "LocalServerCodeReceiver.cs:line line 86" is not going well. There is a Process start at the line which fails !!!! Why ????? I have the latest nuggets for Google.Apis (Google.Apis v1.20.0, Google.Apis.Auth v1.20.0, Google.Apis.Blogger.v3 1.20.0.111, Google.Apis.Core v1.20.0, Google.Apis.Oauth2.v2 v1.20.0.672)
Please help me, I can provide more info if needed, even the solution and everything that will help me to use Google Api to insert and update Blogger posts from .NET.
The stacktrace is:
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Google.Apis.Auth.OAuth2.LocalServerCodeReceiver.d__6.MoveNext() in C:\Apiary\v1.20\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\LocalServerCodeReceiver.cs:line 86
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Apis.Auth.OAuth2.AuthorizationCodeInstalledApp.d__8.MoveNext() in C:\Apiary\v1.20\google-api-dotnet-client\Src\Support\GoogleApis.Auth\OAuth2\AuthorizationCodeInstalledApp.cs:line 77
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__4.MoveNext() in C:\Apiary\v1.20\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 134
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.d__1.MoveNext() in C:\Apiary\v1.20\google-api-dotnet-client\Src\Support\GoogleApis.Auth.DotNet4\OAuth2\GoogleWebAuthorizationBroker.cs:line 60
The text was updated successfully, but these errors were encountered: