Google API V3 OAUTH2 Hang - TokenResponse-user Credentials File not created

爷,独闯天下 提交于 2019-12-05 20:53:37
Mike Meinz

I have found a solution. Here is how I arrived at the solution.

I decided to try copying the Google.Apis.Auth.OAuth2.Responses.TokenResponse-user from my Windows 8.1 PC to my Windows 7 PC to see if a refresh of the token file would work because a first time creation of the token file did not work. A refresh did work. The GoogleWebAuthorizationBroker.AuthorizeAsync did a refresh of the token file and exited properly back to my EXE program.

But, another problem surfaced.

In the next step of my EXE program, while executing a ChannelsResource.ListRequest, I got this error message box:

Could not load type 'System.Net.HttpStatusCode' from assembly 'System.Net, Version 4.0.9.9, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

A search revealed that someone else had seen the same error and was advised to install Microsoft .NET Framework 4.0 update KB2468871. I did so and now my ChannelsResource.ListRequest executed properly.

I deleted the Google.Apis.Auth.OAuth2.Responses.TokenResponse-user token file and re-ran my EXE program executing the GoogleWebAuthorizationBroker.AuthorizeAsync to create a new token file. This time it worked properly.

My conclusion is that the same Could not load type 'System.Net.HttpStatusCode' exception occurred during the execution of GoogleWebAuthorizationBroker.AuthorizeAsync but it was not trapped and reported.

Google API V3 Documentation

The following prerequisite requirement should be added to the Google API V3 documentation:

Install Microsoft .NET Framework 4.0 update KB2468871 (http://www.microsoft.com/en-us/download/details.aspx?id=3556)

N.B. Later, after experiencing yet another problem, I discovered that the Windows 7 PC did not have all of the latest updates from Windows Update. Using Windows Update to get all of the updates solved the problem documented in System.InvalidOperationException in MSCORLIB when Google API V3 .UploadAsync is called

Further Information

I had to manually add the following files that were installed in the project's folder from NuGet into the InstallShield LE Setup Project's Files tab so that they would be copied to the target system. For some reason, the InstallShield LE Setup project did not automatically add these files. It added all of the others.

System.Net.Http.dll
System.Net.Http.WebRequest.dll
System.Runtime.dll
System.Threading.Tasks.dll
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!