Perl6 OAuth2 Client for Google
Switch branches/tags
Nothing to show


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