16 Dec 2019 02:52:03 UTC
- Distribution: GitHub-Apps-Auth
- Module version: 0.04
- Source (raw)
- Browse (raw)
- How to Contribute
- Testers (33 / 0 / 0)
- KwaliteeBus factor: 1
- 77.58% Coverage
- License: perl_5
- Perl: v5.8.1
- Activity24 month
- Download (11.53KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
- OPERATOR OVERLOADS
- SEE ALSO
GitHub::Apps::Auth - The fetcher that get a token for GitHub Apps
use GitHub::Apps::Auth; my $auth = GitHub::Apps::Auth->new( private_key => "<filename>", # when read private key from file private_key => \$pk, # when read private key from variable app_id => <app_id>, login => <organization or user> ); # This method returns the cached token inside an object. # However, refresh expired token automatically. my $token = $auth->issued_token; # If you want to use with Pithub use Pithub; # GitHub::Apps::Auth object behaves like a string. # This object calls the `issued_token` method # each time it evaluates as a string. my $ph = Pithub->new(token => $auth, ...);
GitHub::Apps::Auth is the fetcher for getting a GitHub token of GitHub Apps.
This module provides a way to get a token that need to be updated regularly for GitHub API.
my $auth = GitHub::Apps::Auth->new( private_key => "<filename>", app_id => <app_id>, installation_id => <installation_id> );
Constructs an instance of
This parameter is a private key of the GitHub Apps.
This must be a filename or string in the pem format. You can get a private key from Settings page of GitHub Apps. See Generating a private key.
This parameter is the App ID of your GitHub Apps. Use the
App IDin the About section of your GitHub Apps page.
Required: exclusive to
installation_idis an identifier of installation Organizations or repositories in GitHub Apps. This value is can be obtained from a webhook that is fired during installation. Also can be obtained from webhook's
Recent Deliveriesof GitHub apps settings.
Required: exclusive to
loginis used for detecting installation_id. If not set
installation_idfrom the list of installations.
my $token = $auth->issued_token;
issued_tokenreturns a API token in string. This token is cached while valid.
When calling this method with condition that expired token, this method refreshes a token automatically.
This method returns an API token. Unlike
issued_token, this method not refresh an expired token.
This returns the token expiration date in the epoch.
GitHub::Apps::Authis overloaded so that
issued_tokenis called when evaluated as a string. So probably be usable in GitHub client that use raw string API token. Ex Pithub.
Copyright (C) mackee.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install GitHub::Apps::Auth, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install GitHub::Apps::Auth
For more information on module installation, please visit the detailed CPAN module installation guide.