Skip to content

Instantly share code, notes, and snippets.

@Dainius14
Last active October 17, 2022 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dainius14/92d188859b0aa87918ddda266e85db91 to your computer and use it in GitHub Desktop.
Save Dainius14/92d188859b0aa87918ddda266e85db91 to your computer and use it in GitHub Desktop.
Gets Facebook access token for use in Tinder application.
using SimpleBrowser;
using System.Threading;
static class FbHelper
{
private static readonly string URL = @"https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=fb464891386855067%3A%2F%2Fauthorize%2F&scope=user_birthday,user_photos,user_education_history,email,user_relationship_details,user_friends,user_work_history,user_likes&response_type=token%2Csigned_request&client_id=464891386855067";
private static readonly string USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19";
public static string GetFbToken(string email, string password)
{
string token = string.Empty;
Browser browser = new Browser();
browser.UserAgent = USER_AGENT;
browser.Navigate(URL);
// Enters email, password and logins
browser.Find(ElementType.TextField, FindBy.Name, "email").Value = email;
browser.Find("u_0_2").Value = password;
browser.Find(ElementType.Button, FindBy.Name, "login").Click();
// If SMS authentication is enabled, after aprooving from the browser manually, clicks ok to continue
while (browser.ContainsText("Enter Security Code to Continue"))
{
browser.Navigate(browser.Url);
Thread.Sleep(1000);
}
// Tinder is already authorized prompt, presses ok
browser.Find("u_0_1").Click();
// access_token= lenght is 13
int indexOfTokenEnd = browser.CurrentHtml.IndexOf("access_token=") + 13;
token = browser.CurrentHtml.Remove(0, indexOfTokenEnd);
token = token.Remove(token.IndexOf("&"));
return token;
}
}
@Colosmican
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment