Re: Sample code to access cloud.google.com / google compute engine ?

William Welliver <[email protected]> Wed, 15 May 2019 11:21:28 -0400 (EDT)
Newsgroups gmane.comp.lang.pike.devel,gmane.comp.lang.pike.user
Message-ID <[email protected]>
I don't have the exact use case you describe, but it seems like the code 
I've used uin the past would work just fine. The idea is that trather than 
initiating a user interactive session that pops up a browser toget a 
token, you already have it, so you can just skip that step and pass the 
token in to the authorization calll. Thus, no user interaction is 
required.

Here's a fairly old example that uses poppa's Social module, which I get 
the feeling has evolved into Web.Auth.

https://bitbucket.org/hww3/pike_demos/src/default/google_apis/google_task_demo.pike

On Wed, 15 May 2019, Stephen R. van den Berg wrote:

> Does anyone happen to have some boilerplate code which they can share
> that uses Pike to get the authorisation tokens required to create
> and delete google compute engine instances?
>
> Basically I need to follow this guide:
>
> https://developers.google.com/identity/protocols/OAuth2ServiceAccount
>
> Which means that I have a private service key from google, and need to
> use this to create a JWT, which can then be used to request a token.
> The token I can then use to call the API.
>
> The question is, how do I use Web.Auth to get my hands on the token?
> The example shown in http://pike.lysator.liu.se/generated/manual/modref/ex/predef_3A_3A/Web/Auth.html
> appears to be geared towards authorisations that require user approval.
>
> In my case I only need to call some Google API (server to server), no userdata
> involved.
> -- 
> Stephen.
>
>