I need some directions because I'm pretty lost. I'm working on a very small app in WinForms and, it uses Google API's. to be able to get to user data I need to get his user name and password, up to this part every thing works but, I don't have any save user ability.
Now, I don't want to ask the user's name and password every time, so I'm trying to find a safe way to do that.
I asked a question about where should I put this info, and got the answer that it is not good idea to save username and passwords, and I should use Google OAuth 2.0 instead.
But, my problem is that I need to use a web browser for Google OAuth 2.0, and now I'm not sure how to implement this in my WinForm app.
My Questions:
Two most important pieces of info for you to know are that you should use a client library to do the work for you, and you should use the "Installed application" flow/client type.
Use the tutorial here, which walks you through using an installed application: https://code.google.com/p/google-api-dotnet-client/wiki/GettingStarted
You do have to use a web browser to get the credentials from the user, but once you do that, you should be able to re-use those credentials (refresh token) without re-prompting. The library makes moving these credentials from the browser to your app simple.
Performing OAuth2 in non-browser application is known as "2-legged OAuth2".
Server-side, 3-legged OAuth2 is for browser authentication. It consist of following steps:
Client-side, 2-legged OAuth2 consist in hosting the WebBrowser control in your application and following steps 2-3 of 3-legged authentication:
redirect event of the web browser control and extract the authentication tokenHaving the user token, the winforms app connects to Google services on behalf of the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With