#!/usr/local/bin/perl -w
###########################################
# token-get - Get the github access token
# Mike Schilli, 2015 (m@perlmeister.com)
###########################################
use strict;
use Net::GitHub;
use Sysadm::Install qw( :all );
use YAML qw( DumpFile );

my $gh_conf = (glob "~")[0] . "/.githubrc";

my $pw = password_read("Password:");
my $gh = Net::GitHub::V3->new( 
  login => 'mschilli', pass => $pw );

my $oauth = $gh->oauth;
my $o = $oauth->create_authorization( {
  scopes => [],
  note   => 'empty scope test',
} );

umask 0077;
DumpFile $gh_conf, 
  { token => $o->{token} };

print "$gh_conf written\n";
