App-Nopaste
view release on metacpan or search on metacpan
lib/App/Nopaste/Service/Gist.pm view on Meta::CPAN
if ($res->is_error) {
my $text = $res->status_line;
if ($res->code == 401) {
$text .= "\nYou may need to authorize $0. See `perldoc " . __PACKAGE__ . "`";
}
return (0, "Failed: " . $text);
}
if (($res->header('Client-Warning') || '') eq 'Internal response') {
return (0, "LWP Error: " . $res->content);
}
my $id = decode_json($res->content)->{id};
return (0, "Could not find paste link.") if !$id;
return (1, "https://gist.github.com/$id");
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Nopaste::Service::Gist - Service provider for GitHub gist - http://gist.github.com/
=head1 VERSION
version 1.013
=for stopwords SIGNES gists oauth plaintext
=head1 GitHub Authorization
In order to create gists you have to get an oauth token. That could be easily
obtained via curl:
curl -X POST 'https://USERNAME:PASSWORD@api.github.com/authorizations' \
-d '{"scopes":["gist"],"note":"App::Nopaste"}'
or you can use this module to do the same:
perl -MApp::Nopaste::Service::Gist -e 'App::Nopaste::Service::Gist->create_token'
You can also generate a token by navigating to L<https://github.com/settings/tokens>
and generate a new token with the 'Create gists' ability.
Then, export the resulting token as the the C<GITHUB_OAUTH_TOKEN> environment
variable. This will grant gist rights to L<App::Nopaste> (or anything else
that Don't worry, you can revoke access rights anytime from the GitHub profile
settings.
Alternatively, you can export the C<GITHUB_USER> and C<GITHUB_PASSWORD>
environment variables, just like for the
L<gist|https://github.com/defunkt/gist> utility.
You can also simply store your credentials in plaintext in F<~/.github> as in:
login bob
password ilikeducks
That's it!
=head1 SUPPORT
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=App-Nopaste>
(or L<bug-App-Nopaste@rt.cpan.org|mailto:bug-App-Nopaste@rt.cpan.org>).
=head1 AUTHOR
Ricardo SIGNES, <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2008 by Shawn M Moore.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 1.554 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )