Skip to content

Instantly share code, notes, and snippets.

@leegee
Created November 13, 2017 08:51
Show Gist options
  • Save leegee/adc181335d015c60d031b075bf0a4032 to your computer and use it in GitHub Desktop.
Save leegee/adc181335d015c60d031b075bf0a4032 to your computer and use it in GitHub Desktop.
Verify Google User with Perl
# @see https://developers.google.com/identity/sign-in/web/backend-auth
sub verify_with_google {
my $self = shift;
my $res = LWP::UserAgent->new()->get(
'https://www.googleapis.com/oauth2/v3/tokeninfo?id_token='
. $self->{id_token}
);
if ($res->is_success() and
$res->decoded_content =~ /"aud"\s*:\s*"$self->{client_id}"/
) {
return 1;
} else {
LOGDIE 'You are not a valid user!';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment