From a76bcdcbcafd855964ced361ce12aa69dd660671 Mon Sep 17 00:00:00 2001 From: Abyr Valg Date: Tue, 8 Aug 2017 15:40:28 +0300 Subject: Document the unknowns --- facebook/facebook-api.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'facebook/facebook-api.h') diff --git a/facebook/facebook-api.h b/facebook/facebook-api.h index 3ed0e41..621800f 100644 --- a/facebook/facebook-api.h +++ b/facebook/facebook-api.h @@ -446,6 +446,39 @@ typedef enum FB_API_MESSAGE_FLAG_SELF = 1 << 2 } FbApiMessageFlags; +/** +* FbApiClientCapabilities: +* @FB_CP_ACKNOWLEDGED_DELIVERY: +* @FB_CP_PROCESSING_LASTACTIVE_PRESENCEINFO: +* @FB_CP_EXACT_KEEPALIVE: +* @FB_CP_REQUIRES_JSON_UNICODE_ESCAPES: +* @FB_CP_DELTA_SENT_MESSAGE_ENABLED: +* @FB_CP_USE_ENUM_TOPIC: All topics are numeric. +* @FB_CP_SUPPRESS_GETDIFF_IN_CONNECT: +* @FB_CP_USE_THRIFT_FOR_INBOX: +* @FB_CP_USE_SEND_PINGRESP: +* @FB_CP_REQUIRE_REPLAY_PROTECTION: +* @FB_CP_DATA_SAVING_MODE: +* @FB_CP_TYPING_OFF_WHEN_SENDING_MESSAGE: +* +* The client capabilities. +*/ +typedef enum +{ + FB_CP_ACKNOWLEDGED_DELIVERY = 1 << 0, + FB_CP_PROCESSING_LASTACTIVE_PRESENCEINFO = 1 << 1, + FB_CP_EXACT_KEEPALIVE = 1 << 2, + FB_CP_REQUIRES_JSON_UNICODE_ESCAPES = 1 << 3, + FB_CP_DELTA_SENT_MESSAGE_ENABLED = 1 << 4, + FB_CP_USE_ENUM_TOPIC = 1 << 5, + FB_CP_SUPPRESS_GETDIFF_IN_CONNECT = 1 << 6, + FB_CP_USE_THRIFT_FOR_INBOX = 1 << 7, + FB_CP_USE_SEND_PINGRESP = 1 << 8, + FB_CP_REQUIRE_REPLAY_PROTECTION = 1 << 9, + FB_CP_DATA_SAVING_MODE = 1 << 10, + FB_CP_TYPING_OFF_WHEN_SENDING_MESSAGE = 1 << 11 +} FbApiClientCapabilities; + /** * FbApi: * -- cgit v1.2.3 From 24db488909604dd389b584c1f1ce43c549648dbe Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 16 Oct 2017 22:11:42 -0300 Subject: Work chat login support (enable the "work" setting to use it) This covers three autodetected login types: 1. Work account password Simple, very similar to normal account types 2. Linked personal account This is deprecated but still needed in some companies. Looks just like password auth to users. In rare cases there may be more than one work account linked to a personal account, in which case this will only use the first one. Usually they can be de-linked by assigning a password (see the official docs) 3. SSO This one is awkward. The password can be set to garbage and users will receive a PM with instructions to do an oauth-like login, but there's no explicit auth code screen, just a redirect to a fb-workchat-sso://, which probably results in an error. Users are expected to copy that url, hopefully from the address bar. Not very practical, but works! In all cases, the username is the work account email. --- facebook/facebook-api.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) (limited to 'facebook/facebook-api.h') diff --git a/facebook/facebook-api.h b/facebook/facebook-api.h index 621800f..2e63471 100644 --- a/facebook/facebook-api.h +++ b/facebook/facebook-api.h @@ -88,6 +88,20 @@ */ #define FB_API_SECRET "374e60f8b9bb6b8cbb30f78030438895" +/** + * FB_WORK_API_KEY: + * + * The Facebook workchat app API key. + */ +#define FB_WORK_API_KEY "312713275593566" + +/** + * FB_WORK_API_SECRET: + * + * The Facebook workchat app API secret. + */ +#define FB_WORK_API_SECRET "d2901dc6cb685df3b074b30b56b78d28" + /** * FB_ORCA_AGENT * @@ -137,6 +151,15 @@ */ #define FB_API_URL_AUTH FB_API_BHOST "/method/auth.login" +/** + * FB_API_URL_WORK_PRELOGIN + * + * The URL for workchat pre-login information, indicating what auth method + * should be used + */ + +#define FB_API_URL_WORK_PRELOGIN FB_API_GHOST "/at_work/pre_login_info" + /** * FB_API_URL_GQL: * @@ -172,6 +195,14 @@ */ #define FB_API_URL_TOPIC FB_API_AHOST "/method/messaging.setthreadname" +/** + * FB_API_SSO_URL: + * + * Template for the URL shown to workchat users when trying to authenticate + * with SSO. + */ +#define FB_API_SSO_URL "https://m.facebook.com/work/sso/mobile?app_id=312713275593566&response_url=fb-workchat-sso%%3A%%2F%%2Fsso&request_id=%s&code_challenge=%s&email=%s" + /** * FB_API_QUERY_CONTACT: * @@ -319,6 +350,16 @@ */ #define FB_API_QUERY_XMA 10153919431161729 +/** + * FB_API_WORK_COMMUNITY_PEEK: + * + * The docid with information about the work community of the currently + * authenticated user. + * + * Used when prelogin returns can_login_via_linked_account + */ +#define FB_API_WORK_COMMUNITY_PEEK 1295334753880530 + /** * FB_API_CONTACTS_COUNT: * @@ -674,12 +715,49 @@ fb_api_error_emit(FbApi *api, GError *error); * @api: The #FbApi. * @user: The Facebook user name, email, or phone number. * @pass: The Facebook password. + * @credentials_type: Type of work account credentials, or NULL * * Sends an authentication request to Facebook. This will obtain * session information, which is required for all other requests. */ void -fb_api_auth(FbApi *api, const gchar *user, const gchar *pass); +fb_api_auth(FbApi *api, const gchar *user, const gchar *pass, const gchar *credentials_type); + +/** + * fb_api_work_login: + * @api: The #FbApi. + * @user: The Facebook user name, email, or phone number. + * @pass: The Facebook password. + * + * Starts the workchat login sequence. + */ +void +fb_api_work_login(FbApi *api, gchar *user, gchar *pass); + +/** + * fb_api_work_gen_sso_url: + * @api: The #FbApi. + * @user: The Facebook user email. + * + * Generates the URL to be shown to the user to get the SSO auth token. This + * url contains a challenge and the corresponding verifier is saved in the + * FbApi instance to be used later. + * + * Returns: a newly allocated string. + */ +gchar * +fb_api_work_gen_sso_url(FbApi *api, const gchar *user); + +/** + * fb_api_work_got_nonce: + * @api: The #FbApi. + * @url: The fb-workchat-sso:// URL as entered by the user + * + * Parses the fb-workchat-sso:// URL that the user got redirected to and + * continues with work_sso_nonce auth + */ +void +fb_api_work_got_nonce(FbApi *api, const gchar *url); /** * fb_api_contact: -- cgit v1.2.3