Last active
February 5, 2022 06:29
The script shows all Google APIs scopes via Google APIs Discovery Service. Run like below.$ perl google-api-scopes.pl | sort | uniq
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use 5.010000; | |
use JSON; | |
use LWP::UserAgent; | |
use URI; | |
my $services_url = 'https://www.googleapis.com/discovery/v1/apis/?fields=items/discoveryRestUrl'; | |
my $ua = LWP::UserAgent->new; | |
my $res = $ua->get($services_url); | |
unless ($res->is_success) { | |
die $res->status_line; | |
} | |
my $content = JSON->new->decode($res->content); | |
for my $item (@{$content->{items}}) { | |
my $scope_url = URI->new($item->{discoveryRestUrl}); | |
$res = $ua->get($scope_url); | |
unless ($res->is_success) { | |
warn $res->status_line; | |
next; | |
} | |
my $scopes = JSON->new->decode($res->content); | |
my $scopes_hashref = $scopes->{auth}{oauth2}{scopes}; | |
for my $scope (keys %{$scopes_hashref}) { | |
say $scope . ' - ' . $scopes_hashref->{$scope}{description}; | |
} | |
} | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Although https://cloudsupport.googleapis.com/$discovery/rest?version=v2beta returned 404 so far.)