Created
November 13, 2017 08:51
-
-
Save leegee/adc181335d015c60d031b075bf0a4032 to your computer and use it in GitHub Desktop.
Verify Google User with Perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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