VUser:...otocol(3pm)

πŸ“¦
version 1.0.1 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– VUser::Google::ApiProtocol β€” the base class glow-up πŸ’–

okay bestie, so this is VUser::Google::ApiProtocol, a 3pm page from the User Contributed Perl Documentation era, and it's literally the base class for implementation of the Google APIs. It's giving foundation, it's giving scaffolding, it's giving "I'm the blueprint, not the building." πŸ—οΈβœ¨


🌸 SYNOPSIS 🌸

So here's the tea, and it's important: this class is not meant to be used directly. Like, at all. Do not pass go, do not collect $200. Instead, use VUser::Google::ApiProtocol::V2_0. That's the one you actually want to be hanging out with. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

(no thoughts, head empty β€” this section is literally blank in the original, so we move on with grace πŸŽ€)


πŸŽ€ MEMBERS πŸŽ€

These are the members of the ApiProtocol class, and the way you get and set them is by calling the method with the same name. Iconic, honestly. For example:

 # Get the domain from the ApiProtocol object
 my $domain = $google->domain;

 # Set the domain
 $google->domain('myappsdomain.com');

Most of the members can be set right when the object is created, using new(), like so:

 my $google = VUser::ApiProtocol->new(
     domain => 'myappsdomain.com'
 );
✨ Note: VUser::Google::ApiProtocol is not meant to be used directly. Please see the version specific subclasses, such as VUser::Google::ApiProtocol::V2_0, to create a usable object. This is a vibe check you cannot skip, bestie.

🌈 Read-write Members 🌈

  • admin β€” The administrative user. This user must have be set as an admin in the Google Apps control panel. Also, be sure to log into the Google Apps control panel once with this user to accept all of the legal garbage or you will see intermittent auth errors. Yes, the legal garbage. Read it once, suffer once, then you're free. 😭
  • debug β€” Turn on debugging output. Lights on, bestie. πŸ”₯
  • domain β€” The Google Apps domain to work on. This is your little corner of the internet. 🏑
  • password β€” The plain text password of the admin user. Keep it secret, keep it safe, do not put it in the group chat. πŸ™ˆ
  • refresh_token β€” If set to a true value, Login() will refresh the authentication token even if it's not necessary. Sometimes you just gotta redo it for the plot. πŸ’…

πŸ’œ Read-only members πŸ’œ

  • authtime β€” The unix timestamp of the last authentication. Time-stamped, no cap. ⏰
  • authtoken β€” The authentication token retrieved from Google on a successful login. The token is only valid for 24 hours. It's giving milk carton β€” it expires, and then it's over. πŸ₯›πŸ’€
  • reply_headers β€” The HTTP headers of the last reply. The receipts, basically. 🧾
  • reply_content β€” The HTTP content of the last reply. The whole entire message, fr fr.
  • result β€” The resulting hash from the last reply data as parsed by XML::Simple. Parsed and delivered, chef's kiss. πŸ‘‘
  • useragent β€” The user agent VUser::Google::ApiProtocol uses when talking to Google. It is set to the classname/version. For example, VUser::Google::ApiProtocol::V2_0/0.25. It knows exactly who it is when it slides into Google's DMs. ✨

⭐ METHODS ⭐

🫢 new (%defaults)

Create a new ApiProtocol object. Any read-write member may be set in the call to new(). Customize her, dress her up, make her yours. πŸŽ€

πŸ“ Login

Login to the Google API. Login() takes no parameters. Instead, you must set the domain, admin, and password members, then call Login(). No shortcuts, no sneaky arguments β€” set the members first, bestie.

Login() will use the existing authentication token if it exists and hasn't yet timed out. You may force it to do a full re-authentication by setting refresh_token to a true value before calling Login(). Sometimes you gotta wipe the slate and start fresh, and that's valid. πŸ’–

🧚 IsAuthenticated

Returns true if the object thinks that it has already authenticated and the token hasn't timed out and a false value otherwise.

😭 Note: IsAuthenticated() only knows if there's an authtoken and if it's still fresh. It may be possible for Google to decide that a token is not valid which IsAuthenticated() cannot check. So like… she's confident, but she's not omniscient. Periodt.

🌸 Request ($method, $url[, $body])

Sends an API request to Google. The main character moment of this whole class, honestly. πŸ”₯

$method is the HTTP method to use, e.g. GET, POST, etc. Note: Many of the API calls use different methods. Double check the API docs to make sure you are using the correct method. Do not guess, do not freestyle β€” read the docs. πŸ’€

$url is the url to use to make the API call. The URLs are defined in the API docs. Go look at them, they're right there.

$body is the XML specific action. Again, see the API docs for the specific format for each API call. $body is not needed when the method is GET or DELETE. So if you're GETting or DELETEing, leave the body at home. ✌️

πŸ’… dprint ($message)

Prints $message to STDERR if debug is set to a true value. A little whisper for when you've turned the debug lights on. 🫢


πŸ’– SEE ALSO πŸ’–

  • XML::Simple

πŸ‘‘ AUTHOR πŸ‘‘

Randy Smith <perlstalker@vuser.org>


πŸŽ€ LICENSE πŸŽ€

(the original has nothing under this heading, so we're leaving it exactly as empty as we found it β€” no cap, nothing to add ✨)


and that's the whole page, bestie! 🌈 this lil masterpiece comes from perl v5.32.0, dated 2021-01-09, and it's filed under VUser:...otocol(3pm) in the User Contributed Perl Documentation collection. go forth and subclass responsibly πŸ’œπŸ¦‹

πŸ“¦ where this page comes from