Google API access from Windows Service

女生的网名这么多〃 提交于 2021-01-28 19:33:39

问题


I implemented Google apps API in a MVC Web app, to access for Admin SDK to add/remove users from Google apps account. In my web app, first the user needs to authenticate with the Google Apps account (OAuth 2.0), then I store the accesstoken and refreshtoken in the database storage. After that,Admin SDK API calls to add/remove user functionality in the web app uses the "offline" mode as it does not pop up the consent screen.

But I need to use my database token storage(accesstokens/refreshtokens) for the authentication. How can I do this?

My requirement is similar to this question. But the issue is that the content is modified and URLs to those samples are no longer there.


回答1:


I could not accomplish this task in a nice way, I had to do few hacks. (In fact as long as the access token is live this can be done, problem occurs is when we need to refresh the token).

Finally I implemented a WebAPI project which can handle token refreshing, works pretty much similar to the MVC app. Windows service communicates with the web API project when it requires the API call and get the response after the job done.



来源:https://stackoverflow.com/questions/31668060/google-api-access-from-windows-service

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