Save sharepoint online credentials? - c#

I have been tasked with creating a console app in asp.net (c#) to query a Sharepoint online list. I can connect to SharePoint using SharepointOnlineCredentials but the user is asked for credentials every time the app is run. Ideally we would like the app to ask the user for the details the first time it runs, save the information and only ask again when or if the users password expires.
I have very little experience with credential and authentication and I do not know the best way to proceed. Would I need to create an encrypted file or could I store a token? Or is there another means of achieving the objective?
Any advise and/or code examples would be appreciated.

Here you can use the Credential Locker
You can download the examples in the page.
Also you will use the PasswordVault class, you can find more information about PasswordVault
The best is to use the Windows API directly in this case. Somethign you will do if you fallow the documentation in the links.
I hope this help you, maybe you will have to do some research and check if there are any issues with asp.net since i did implemented once with a local C# Console app.
Good luck mate.

Related

Login to Google using windows form c#

Hi everyone I have a problem I wanna create app for generate account google drive with api google drive and I don't know how can I login with account from application not navigator C# windows form.
enter image description here
and how can i edit this credential with exist user
Try following these steps:
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-3.1
I have used those steps and worked perfectly for me. You don't have a choice than to be redirected to the Google authentication page.
After entering your Google credentials, you are redirected back to the your site.
My understanding is that you are trying to use Google Drive API from a console application. Or for that matter a fully desktop application.
Take one thing in consideration, if you don't use Service account you must let the user authenticate to google and allow your application to work in his/her behalf. There is no way around this.
What you can do is after the user has already signed in, is to save the tokens and refresh them whenever necessary.
Of course OAuth may be complicated, but you use the .NET library everything will be managed for you. And you can look at a real example in the .NET Drive Quickstart

login website like(FB, TWITTER ) and crawl data with c#?

I am creating a console application in c#(visual studio).
but i don't know where to start.
1st i want to login(phantomjs or selenium)>>then go to a (specified)website URL and extract html?
i want to know how to save login information in my web request.
thank you.
Long story short, it's not easy to do that just with web request because each site has its own way of managing cookies and security.
It's easier if you use a web browser control to login first. From there, the browser can obtain a valid cookie and you can start crawl data from there.
I've done a similar thing with Chegg website. For details, you can check out my repository https://github.com/hungqcao/chegg-solutions-saver
In your case, it can get a little complicated since FB, Twitter may have 2-factor authentication or something similar to that but the idea stays the same.
Let me know if you need help.

is oAuth possible for C# Windows Application?

I have a windows application, developed in C#. where I need to perform Google oAuth so I'll get their profile. I don't want to ask the user to enter their Google Username and Password in my windows application (and of course users don't want that).
How can I do that ?
I tried
1.) Able to open Google Authentication page from my windows application, but can't figure it out how to get access token passed to my windows application.
Any inputs / suggestions ?
You can have a webBrowser control in you application. You can then let the user log in via the webBrowser control. You can then query the webBrowser control for the data.
What you are probably looking for is called 2-legged OAuth. You can get some example code here, but its in PHP. You can also see a C# Example here
I appreciate this is an old question but I'm currently looking into the same thing. From what I've found, using an embeded webBrowser as per SamFisher83's suggestion is "strongly discouraged".
I thought I'd share this guide from Google themselves.
Link to Google OAuth 2.0 guide
No doubt the OP found a way of doing it, but this was one of the first links that came up via a google search on the subject and thought I'd share the link for any future reference.

Is it possible to login to multiple facebook accounts? (C# 4.0)

I am creating a small desktop application, which would ideally allow multiple facebook users to log in. After they play a game (on one machine), I'd like to be able to individually post their status to their Facebook accounts. This is possible if there is just a single user, but multiple users are causing problems with Sessions and so on. Can anyone advise a way to get around this? Thanks!
To better answer your question, it would help to know how exactly you're connecting to Facebook from your game software.
In general, if you're using OAuth tokens to do it, try keeping separate sets of access tokens and pass along each one when appropriate.

facebook offline access using c#

i am developing a notification service in c# for our web site. its windows service no ui (asp.net / winform). This service will run on certain time and post something on users wall. i use social plug-in in our web site where user can grant required permission. Based on this i have few question
1) is there any c# library or sdk available for Facebook.
2) what information i have to store in order to access facebook offline.
i hope my question is clear. thanks for any help.
Update 1: i really need help on this. thanks once again.
There is a facebook API that can be used, http://developers.facebook.com/
You can't access facebook offline? I mean, if you wanted to save current information while online and then re-access the old information while offline that is possible just by saving the webpages, but you cannot access any new information. so your not really accessing facebook..
You'll need the user to log in, and there's a permission you can request that makes the session you get permanent. You'll have to have some kind of installer or something that will have the user log in, grant that permission, and then you'll save that access token. UI-wise, look at digsby, and notice how they make you log in to facebook the first time you link your facebook account.
i found this one and its helpful
http://blog.theunical.com/facebook-integration/simple-5-steps-to-publish-on-a-facebook-wall-using-dotnet-c/

Categories