|
|
@@ -261,20 +261,25 @@
|
|
|
:parser 'json-read
|
|
|
:success (cl-function
|
|
|
(lambda (&key data &allow-other-keys)
|
|
|
- (cond
|
|
|
- ((exitter-find-subtask data "LoginSuccessSubtask")
|
|
|
- (message "LoginSuccessSubtask")
|
|
|
- (let* ((subtask
|
|
|
- (exitter-find-subtask data "LoginSuccessSubtask"))
|
|
|
- (open-account (alist-get 'open_account subtask)))
|
|
|
- (setq exitter-oauth-token
|
|
|
- (alist-get 'oauth_token open-account)
|
|
|
- exitter-oauth-token-secret
|
|
|
- (alist-get 'oauth_token_secret open-account)
|
|
|
- exitter-oauth-token-ctime
|
|
|
- (format-time-string "%Y-%m-%d %a %H:%M:%S"
|
|
|
- (current-time)))))
|
|
|
- (t (message "Cannot find any matching subtasks"))) ))
|
|
|
+ (let ((new-flow-token
|
|
|
+ (alist-get 'flow_token data)))
|
|
|
+ (cond
|
|
|
+ ((exitter-find-subtask data "LoginSuccessSubtask")
|
|
|
+ (let* ((subtask
|
|
|
+ (exitter-find-subtask data "LoginSuccessSubtask"))
|
|
|
+ (open-account (alist-get 'open_account subtask)))
|
|
|
+ (message (format "Account: %s" open-account))
|
|
|
+ (setq exitter-oauth-token
|
|
|
+ (alist-get 'oauth_token open-account)
|
|
|
+ exitter-oauth-token-secret
|
|
|
+ (alist-get 'oauth_token_secret open-account)
|
|
|
+ exitter-oauth-token-ctime
|
|
|
+ (format-time-string "%Y-%m-%d %a %H:%M:%S"
|
|
|
+ (current-time)))))
|
|
|
+ ((exitter-find-subtask data "LoginTwoFactorAuthChallenge")
|
|
|
+ (message "LoginTwoFactorAuthChallenge")
|
|
|
+ (exitter-enter-two-factor new-flow-token headers))
|
|
|
+ (t (message "Cannot find any matching subtasks"))))))
|
|
|
:error
|
|
|
(cl-function (lambda (&rest args &key error-thrown &allow-other-keys)
|
|
|
(message "Got error: %S" error-thrown)))
|
|
|
@@ -309,6 +314,41 @@
|
|
|
(message "Got error: %S" error-thrown)))
|
|
|
))
|
|
|
|
|
|
+(defun exitter-enter-two-factor (flow-token headers)
|
|
|
+ (when exitter-debug (message "entering exitter-enter-two-factor"))
|
|
|
+ (request exitter-url-task
|
|
|
+ :params '(("lang" . "en"))
|
|
|
+ :headers headers
|
|
|
+ :data (json-encode
|
|
|
+ `(("flow_token" . ,flow-token)
|
|
|
+ ("subtask_inputs" .
|
|
|
+ [(("enter_text" .
|
|
|
+ (("text" . ,(read-string "Two-factor code: "))
|
|
|
+ ("link" . "next_link")))
|
|
|
+ ("subtask_id" . "LoginTwoFactorAuthChallenge"))])))
|
|
|
+ :type "POST"
|
|
|
+ :parser 'json-read
|
|
|
+ :success (cl-function
|
|
|
+ (lambda (&key data &allow-other-keys)
|
|
|
+ (cond
|
|
|
+ ((exitter-find-subtask data "LoginSuccessSubtask")
|
|
|
+ (let* ((subtask
|
|
|
+ (exitter-find-subtask data "LoginSuccessSubtask"))
|
|
|
+ (open-account (alist-get 'open_account subtask)))
|
|
|
+ (message (format "Account: %s" open-account))
|
|
|
+ (setq exitter-oauth-token
|
|
|
+ (alist-get 'oauth_token open-account)
|
|
|
+ exitter-oauth-token-secret
|
|
|
+ (alist-get 'oauth_token_secret open-account)
|
|
|
+ exitter-oauth-token-ctime
|
|
|
+ (format-time-string "%Y-%m-%d %a %H:%M:%S"
|
|
|
+ (current-time)))))
|
|
|
+ (t (message "Cannot find any matching subtasks")))))
|
|
|
+ :error
|
|
|
+ (cl-function (lambda (&rest args &key error-thrown &allow-other-keys)
|
|
|
+ (message "Got error: %S" error-thrown)))))
|
|
|
+
|
|
|
+
|
|
|
;;; Example at
|
|
|
;;; https://developer.x.com/en/docs/authentication/oauth-1-0a/creating-a-signature
|
|
|
;;; should produce signature "Ls93hJiZbQ3akF3HF3x1Bz8%2FzU4%3D"
|