Perl6 OAuth2 Client for Google
Switch branches/tags
Nothing to show
Latest commit e65fd65 Apr 27, 2017 @bduggan committed on GitHub Merge pull request #2 from samcv/SPDX-license
Use SPDX identifier in license field of
Failed to load latest commit information.
eg verify-id Jul 28, 2016
lib/OAuth2/Client comment format Aug 9, 2016
t scope Jul 28, 2016
.gitignore gitignore Jul 27, 2016
.travis.yml travis, meta Jul 28, 2016
LICENSE license and example Jul 28, 2016 Use SPDX identifier in license field of Apr 27, 2017
META.json Add mandatory "perl" META field Oct 26, 2016 syntax highlighting Jul 29, 2016
id.p6 fixed meta Aug 9, 2016


Authenticate with Google using OAuth2.

Build Status

For details see

Quick How-to

  1. Go to and create a project.

  2. Set up credentials for a web server and set your redirect URIs.

  3. Download the JSON file (client_id.json).

  4. In your application, create an oauth2 object like this:

 my $oauth =
    config => from-json('./client_id.json'.IO.slurp),
    redirect-uri => 'http://localhost:3334/oauth',
    scope => 'email'

where redirect-uri is one of your redirect URIs and scope is a space or comma-separated list of scopes from

To authenticate, redirect the user to


Then when they come back and send a request to '/oauth', grab the "code" parameter from the query string. Use it to call

my $token = $oauth.code-to-token(code => $code)

This will give you $token<access_token>, which you can then use with google APIs.

If you also included "email" in the scope, you will get id-token, which you can use like this:

my $identity = $oauth.verify-id(id-token => $token<id_token>)

which has, e.g. $identity<email> and $identity<given_name>.

For a working example, see eg/get-calendar-data.p6.


  • Better documentation
  • Refresh tokens