Facebook-OpenGraph
    
    
  
  
  
view release on metacpan or search on metacpan
lib/Facebook/OpenGraph.pm view on Meta::CPAN
# Access Tokens > App Tokens
# https://developers.facebook.com/docs/facebook-login/access-tokens/#apptokens
sub get_app_token {
    my $self = shift;
    # Document does not mention what grant_type is all about or what values can
    # be set, but RFC 6749 covers the basic idea of grant types and its Section
    # 4.4 describes Client Credentials Grant.
    # http://tools.ietf.org/html/rfc6749#section-4.4
    return $self->_get_token(+{grant_type => 'client_credentials'});
}
# Manually Build a Login Flow > Confirming identity > Exchanging code for an access token
# https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
sub get_user_token_by_code {
    my ($self, $code) = @_;
    croak 'code is not given'        unless $code;
    croak 'redirect_uri must be set' unless $self->redirect_uri;
t/002_retrieve/01_get_app_token.t view on Meta::CPAN
            is_deeply $args{headers}, [], 'no particular header';
            my $uri = $args{url};
            is $uri->scheme, 'https', 'scheme';
            is $uri->host, 'graph.facebook.com', 'host';
            is $uri->path, '/oauth/access_token', 'path';
            is_deeply(
                +{
                    $uri->query_form,
                },
                +{
                    grant_type    => 'client_credentials',
                    client_secret => 'secret',
                    client_id     => 123456789,
                },
                'query',
            );
            is $args{method}, 'GET', 'HTTP GET method';
            is $args{content}, '', 'content';
            return (
                1,
( run in 0.821 second using v1.01-cache-2.11-cpan-c333fce770f )