gcp: add token type

Also use it in -get-gcp-jwt.
This commit is contained in:
J 2021-02-24 00:45:33 +00:00
parent a8113182a8
commit d94f35aa5c
2 changed files with 10 additions and 4 deletions

6
pkg/arvo/sur/gcp.hoon Normal file
View File

@ -0,0 +1,6 @@
|%
+$ token
$: access=@t
expiry=@da
==
--

View File

@ -17,7 +17,7 @@
:: with a bearer token and expiry.
::
::
/- spider, settings
/- gcp, spider, settings
/+ jose, pkcs, primitive-rsa, strandio
=, strand=strand:spider
=, rsa=primitive-rsa
@ -35,9 +35,9 @@
'https://www.googleapis.com/auth/devstorage.read_write'
=/ jot=@t
(make-jwt key kid iss scope aud now.bowl)
;< p=[access-token=@t expires-at=@da] bind:m
;< =token:gcp bind:m
(get-access-token jot aud now.bowl)
(pure:m !>(p))
(pure:m !>(token))
::
++ read-setting
|= key=term
@ -100,7 +100,7 @@
::
++ get-access-token
|= [jot=@t url=@t now=@da]
=/ m (strand ,[@t @da]) ^- form:m
=/ m (strand ,token:gcp) ^- form:m
;< ~ bind:m
%: send-request:strandio
method=%'POST'