Facebook JS SDK + C# SDK Logic - c#

I've been playing around with Facebook JavaScript SDK and Facebook SDK for .NET (Web) to try and create a simple Page tab app which does the below:
Show welcome page
If user likes the page, ask for proper extended permissions and redirect to another page reserved for fans only
Use the access token from the login to do things on the user behalf.
Anyway, my problem is with the logic of the whole thing, as the user enters the page what should I do after loading the JS SDK? It automatically shows the permissions box so that I could get the extended permissions user_likes instead of showing the welcome page.
My other issue is with the access token that is going to be used later in time. Should i store it in session state? if yes, how? What happens if i try to access it and it's expired?
I know this is a general question but please could someone guide me through the best practices to initialize and use the facebook SDK in a .NET WebForms tab app?
Thanks a lot.
(I've read through both docs on Facebook and C# SDK. Great for browsing the API but not much documentations or examples about .NET WebForms)

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

how can login to google account in c#? need sample

i try to login google account with c# windows app. but i have this error error
When I am trying to login via browser in my application it keeps saying "Couldn't sign you in" This browser or app may not be secure. i need sample
Google won't let you sign-in via an embedded browser for exactly the reason stated - it's not secure. To do so programmatically you need to use their API. Unfortunately this problem is far larger in scope than what an answer here on SO warrants, so here's some links:
Documentation on the .NET API (including samples) can be found here
More info on supported browsers and why this might not be one of them can be found here

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.

Creating a hook into my facebook app from another site

new to facebook dev and I have read the basics to get a site up and running using the canvas setup. Nice and simple, I have also got the integration with users working ok (i.e. the signed_request).
I was wondering how it works with "sending/posting" data from one site that is anonymous (my own external to facebook) to the facebook site.
The flow I'm after is a user is looking at some content my site A (my own external site) and then clicks the "share on facebook" button (or whatever), which sends the user (and the data they were looking at) to the site B (my facebook app) to which they authenticate and then (and this is the part I dont get) can see that content on their personalised homepage within site B.
So is there a way to POST some kind of data to the facebook site? Or do I need to do something else here?
Thanks a lot.
You use the facebook API located here:
http://github.com/facebook/csharp-sdk
The .zip download includes the api that you can compile, as well as a sample project that uses it.
Reference: http://developers.facebook.com/blog/post/395/
EDIT
Here is some more info regarding the facebook graph api. I think you'll find everything you need in here: http://developers.facebook.com/docs/reference/api/

Simple Facebook Connect Demo in ASP.NET

Does anyone have a simple and successful demo implementation of facebook connect in an asp.net application. I am developing an asp.net web application and want facebook connect to be the primary method for logging in.
I was having troubles as well, but found that this stackoverflow question got me on the right track as far as the server side stuff is concerned
However, First you have to get the facebook connect button working from here Facebook Wiki
Then detect if they are logged in or not and redirect them appropriately to a welcome page.
Detect login via Javascript
Most other actions can be done via serverside with the Facebook ToolKit. (eg get their information, friends, etc..)
The last thing I think I should mention is logging the user out, so take a look at this. Facebook Wiki: Logout
Hope this helps
As I see, all the above examples and links are really outdated. The new Facebook Graph API makes the whole process a lot easier, without the need for any other components:
http://area72.ro/general-it/how-to-login-via-facebook-in-asp-net.html
try to use the toolkit called Facebook Developer Toolkit
you have in Steve Blog a post about it, and you even download he's Starter Kit so you can view all the code :)
Hope it helps
I know you asked for ASP.NET resources. The Facebook Connect page provides some good information as well as the source to a sample implementation using PHP. Hopefully you can pull some good information from the PHP code.
http://developers.facebook.com/connect.php Check out the links on the right side.
The provided demo can be accessed here... http://www.somethingtoputhere.com/therunaround/

Categories