urbit/sec/com/googleapis.hoon

56 lines
1.5 KiB
Plaintext
Raw Normal View History

2016-03-04 23:27:54 +03:00
:: Test url +https://www.googleapis.com/oauth2/v1/userinfo
::
2016-03-05 03:24:23 +03:00
:::: /hoon/googleapis/com/sec
2016-03-04 23:27:54 +03:00
::
2016-04-07 23:07:21 +03:00
/+ oauth2, interpolate, hep-to-cab
::
::::
::
|%
2016-02-19 23:33:56 +03:00
++ user-state {ber/token ref/refresh}:oauth2
2016-01-28 00:58:28 +03:00
++ suffix-email
%+ cook welp
;~ plug
(star ;~(less pat prn))
;~(pose (plus prn) (easy "@gmail.com"))
==
::
++ auth-usr
2016-02-19 23:33:56 +03:00
|= usr/iden
2016-01-28 00:58:28 +03:00
=+ lon=(fall (slaw %t usr) usr)
2016-04-07 23:07:21 +03:00
%+ add-query:interpolate 'https://accounts.google.com/o/oauth2/v2/auth'
%- quay:hep-to-cab
2016-04-07 23:07:21 +03:00
:~ login-hint+?~(lon '' (crip (rash lon suffix-email)))
access-type+%offline
response-type+%code
prompt+%consent
2016-01-16 02:30:15 +03:00
==
2016-01-27 04:44:14 +03:00
++ scopes
:~ 'https://mail.google.com'
'https://www.googleapis.com/auth/plus.me'
'https://www.googleapis.com/auth/userinfo.email'
==
2016-01-27 04:44:14 +03:00
::
++ exchange-url 'https://www.googleapis.com/oauth2/v4/token'
--
!:
::::
::
|_ {bal/(bale keys:oauth2) own/user-state}
:: ++auth is a "standard refreshing 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.
++ auth
=+ a=~(standard-refreshing oauth2 bal ber.own)
(a(state-usr &) ..auth ref.own |=(a/user-state ..auth(own a)))
::
++ filter-request (out-refresh-or-add-header:auth exchange-url scopes dialog-url)
++ dialog-url (auth-usr usr.bal)
2016-02-17 05:21:45 +03:00
::
++ filter-response res-save-after-refresh:auth
2016-01-27 04:44:14 +03:00
::
++ receive-auth-query-string (in-code-to-token:auth exchange-url)
++ receive-auth-response bak-save-both-tokens:auth
:: ++ update *user-state
--