Skip to content

Instantly share code, notes, and snippets.

@jeffa
Last active December 23, 2015 09:39
Show Gist options
  • Select an option

  • Save jeffa/6616207 to your computer and use it in GitHub Desktop.

Select an option

Save jeffa/6616207 to your computer and use it in GitHub Desktop.
Google APIs Client Library for Perl
#!/usr/bin/env perl
package LWP::Authen::OAuth2::Dancer;
our $VERSION = '0.1';
use Dancer ':syntax';
use LWP::Authen::OAuth2;
our $oauth2 = LWP::Authen::OAuth2->new(
client_id => '',
client_secret => '',
service_provider => 'Google',
redirect_uri => 'http://www.example.com/oauth2callback',
scope => 'https://www.googleapis.com/auth/calendar',
);
get '/' => sub { '<a href="/oauth2authorize">auth</a>' };
get '/oauth2authorize' => sub { redirect $oauth2->authorization_url, 303 };
get '/oauth2callback' => sub { content_type 'text/plain'; to_yaml { params } };
package main;
use Dancer;
dance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment