From a531c4538f59889b3a98abd87035a709b54b3fb4 Mon Sep 17 00:00:00 2001 From: Anton Dyudin Date: Tue, 19 Jan 2016 16:03:24 -0800 Subject: [PATCH] port fb driver forward --- sec/com/facebook/graph.hoon | 72 +++++++++++++++++++++++++++++++++++-- sec/com/googleapis/www.hoon | 3 +- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/sec/com/facebook/graph.hoon b/sec/com/facebook/graph.hoon index 748a09982..3f032bc43 100644 --- a/sec/com/facebook/graph.hoon +++ b/sec/com/facebook/graph.hoon @@ -1,2 +1,70 @@ -=+ toke=XX -|=(a=hiss %_(a r.p :_(r.p.a 'access_token'^toke))) +|% +++ bowl-ish ,~ +++ fass :: rewrite quay + |= a=quay + %+ turn a + |= [p=@t q=@t] ^+ +< + [(gsub '-' '_' p) q] +:: +++ gsub :: replace chars + |= [a=@t b=@t t=@t] + ^- @t + ?~ t t + %+ add (lsh 3 1 $(t (rsh 3 1 t))) + =+ c=(mod t (bex 8)) + ?:(=(a c) b c) +-- +:: +:::: + :: +=+ :- client-id='255263714659582' + client-secret=XX +|_ [bowl-ish ber=@t] +++ redirect-uri 'http://localhost:8443/~/ac/graph.facebook.com/auth' +++ aut + ^- quay + %- fass + :~ client-id/client-id + redirect-uri/redirect-uri + scope/'user_about_me user_posts' + == +:: +++ out + |= a=hiss + ?~ ber [%| [& ~ `/com/facebook/www] `/dialog/oauth aut] + [%& %_(a r.p :_(r.p.a 'access_token'^ber))] +:: +:: +++ graph [& ~ `/com/facebook/graph] +++ in + |= a=quay ^- (each hiss ,_!!) + =+ cod=~|(%no-code (~(got by (mo a)) %code)) + =- [%& [graph `/'v2.3'/oauth/'access_token' -] %get ~ ~] + %- fass + :~ code/cod + client-id/client-id + client-secret/client-secret + redirect-uri/redirect-uri + grant-type/'authorization_code' + == +:: +:: +++ parse-bak + |= [@u a=@t] + %. a + ;~ biff + poja + => jo %- ot :~ + 'access_token'^so + 'expires_in'^ni + == + == +:: +++ bak + |= res=httr ^- [(each ,_!! ,%retry) _+>] + =+ ~| bad-json/r.res + ^- [ber=@t tim=@u] + (need (parse-bak (need r.res))) + :- [%| %retry] :: XX handle timeout + +>.$(ber ber) +-- diff --git a/sec/com/googleapis/www.hoon b/sec/com/googleapis/www.hoon index e339133e9..e0fed31b3 100644 --- a/sec/com/googleapis/www.hoon +++ b/sec/com/googleapis/www.hoon @@ -51,7 +51,6 @@ :: |_ [bowl-ish user-state] ++ out - :: XX dynamic |= a=hiss ^- (each hiss purl) ?~ ber [%| (auth-url client-id 'userinfo.email' 'plus.me' ~)] [%& %_(a q.q (~(add ja q.q.a) %authorization (cat 3 'Bearer ' ber)))] @@ -86,6 +85,6 @@ =+ ~| bad-json/r.res ^- [@ ber=@t ref=@t tim=@u] (need (parse-bak (need r.res))) - :- [%| %retry] :: XX refresh + :- [%| %retry] :: XX schedule token refresh +>.$(ber ber) --