问题
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