in reply to Getting Moo::Google working with People API

So, I've been able to make some more headway on this by delving into the code of Moo::Google::Client.pm. There is a method in that module called build_http_transaction. The method passes a $path scalar to a build_tx subroutine in mojolicious. The $path scalar is set by inspecting Google's discovery api and has the value of https://people.googleapis.com/v1/{+resourceName} for the API call here. If I hard code the path to:

https://people.googleapis.com/v1/people/me and make the API call through Moo::Google with $r1->People->get({options => {personFields => 'emailAddresses'} )->json; I can actually get it to work and return results.

So now the question is, how do I make the call via Moo::Google so that {+resourceName} in the path gets replaced with people/me? Maybe this is impossible with Moo::Google?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^2: Getting Moo::Google working with People API
by localshop (Monk) on Oct 03, 2018 at 21:30 UTC

    NB - Steve Dondleyhas copied Moo-Google into the cpan WebService::Google namespace. It should be noted that the code as of writing this is not yet ready for prime time but Steve is working on it so I am hopeful that it becomes usable soon.

    If looking to use this as a generic Google API interface be warned that although the agent works well for handling to OAUTH tokens, the dynamic classing isn't really usable except for the Calendar API. There is a lower level method that can be used to construct the endpoints and do REST directly which is really the only way you should expect to use this at the moment. The idea of autoclass generation for the API's based on the Google API discovery endpoints is a kinda cool ambition but it seems to break down quickly with the current implementation as only the top level methods can be used.

    An alternative approach for those seeking to make extended use of the Google API's might be to use the swagger specs as per https://github.com/APIs-guru/openapi-directory/tree/master/APIs/googleapis.com with something like Mojolicious::Plugin::OpenAPI as described at https://mojolicious.io/blog/2017/12/22/day-22-how-to-build-a-public-rest-api/

    If anybody goes down that path I'd love to here on the level of success. For my use cases I'm using the low level methods in my own version of WebService::Google::Client for GMail, GMB, Sheets etc so if anybody needs a hand on this front feel to reach out.