urbit/sec/com/facebook.hoon

43 lines
1.2 KiB
Plaintext
Raw Normal View History

2016-03-04 23:27:54 +03:00
:: Test url +https://graph.facebook.com/v2.5/me
::
2016-03-05 03:24:23 +03:00
:::: /hoon/facebook/com/sec
2016-03-04 23:27:54 +03:00
::
2016-01-26 01:49:38 +03:00
/+ oauth2
2016-01-20 03:03:24 +03:00
::
::::
::
2016-04-08 04:39:48 +03:00
|%
++ dialog-url 'https://www.facebook.com/dialog/oauth?response_type=code'
++ exchange-url 'https://graph.facebook.com/v2.3/oauth/access_token'
--
::
::::
::
|_ {bal/(bale keys:oauth2) access-token/token:oauth2}
:: ++aut is a "standard oauth2" core, which implements the
:: most common handling of oauth2 semantics. see lib/oauth2 for more details,
:: and examples at the bottom of the file.
2016-04-08 04:39:48 +03:00
++ aut
%+ ~(standard oauth2 bal access-token) .
|=(access-token/token:oauth2 +>(access-token access-token))
::
++ filter-request
2016-04-08 04:39:48 +03:00
%^ out-add-query-param:aut 'access_token'
scope=~['user_about_me' 'user_posts']
dialog-url
::
++ receive-auth-query-string (in-code-to-token:aut exchange-url)
2016-04-08 04:39:48 +03:00
::
++ receive-auth-response
2016-04-08 04:39:48 +03:00
|= a/httr ^- core-move:aut
?: (bad-response:aut p.a)
2016-04-08 04:39:48 +03:00
[%give a] :: [%redo ~] :: handle 4xx?
=+ `{access-token/@t expires-in/@u}`(grab-expiring-token:aut a)
?. (lth expires-in ^~((div ~d7 ~s1))) :: short-lived token
[[%redo ~] ..bak(access-token access-token)]
:- %send
%^ request-token:aut exchange-url
2016-04-08 04:39:48 +03:00
grant-type='fb_exchange_token'
[key='fb_exchange_token' value=access-token]~
2016-01-20 03:03:24 +03:00
--