| 1 | package Facebook::Graph::Authorize; | ||||||||||
| 2 | 4 | $Facebook::Graph::Authorize::VERSION = '1.1205'; | |||||||||
| 3 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | with 'Facebook::Graph::Role::Uri'; | |||||||||
| 5 | |||||||||||
| 6 | 4 | has app_id => ( | |||||||||
| 7 | is => 'ro', | ||||||||||
| 8 | required=> 1, | ||||||||||
| 9 | ); | ||||||||||
| 10 | |||||||||||
| 11 | 4 | has postback => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | required=> 1, | ||||||||||
| 14 | ); | ||||||||||
| 15 | |||||||||||
| 16 | has permissions => ( | ||||||||||
| 17 | is => 'rw', | ||||||||||
| 18 | lazy => 1, | ||||||||||
| 19 | predicate => 'has_permissions', | ||||||||||
| 20 | 0 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 21 | 4 | ); | |||||||||
| 22 | |||||||||||
| 23 | has display => ( | ||||||||||
| 24 | is => 'rw', | ||||||||||
| 25 | 0 | ▶ | default => sub { 'page' }, | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 26 | 4 | ); | |||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub extend_permissions { | ||||||||
|
Subroutine
extend_permissions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 0 | my ($self, @permissions) = @_; | |||||||||
| 30 | 0 | push @{$self->permissions}, @permissions; | |||||||||
| 31 | 0 | return $self; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 0 | ▶ | sub set_display { | ||||||||
|
Subroutine
set_display: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 35 | 0 | my ($self, $display) = @_; | |||||||||
| 36 | 0 | $self->display($display); | |||||||||
| 37 | 0 | return $self; | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub uri_as_string { | ||||||||
|
Subroutine
uri_as_string: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 41 | 0 | my ($self) = @_; | |||||||||
| 42 | 0 | my $uri = $self->uri; | |||||||||
| 43 | 0 | $uri->path('oauth/authorize'); | |||||||||
| 44 | 0 | my %query = ( | |||||||||
| 45 | client_id => $self->app_id, | ||||||||||
| 46 | redirect_uri => $self->postback, | ||||||||||
| 47 | display => $self->display, | ||||||||||
| 48 | ); | ||||||||||
| 49 | 0 | ▶ | if ($self->has_permissions) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 0 | $query{scope} = join(',', @{$self->permissions}); | |||||||||
| 51 | } | ||||||||||
| 52 | 0 | $uri->query_form(%query); | |||||||||
| 53 | 0 | return $uri->as_string; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 4 | 1; | |||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | =head1 NAME | ||||||||||
| 60 | |||||||||||
| 61 | Facebook::Graph::Authorize - Authorizing an app with Facebook | ||||||||||
| 62 | |||||||||||
| 63 | |||||||||||
| 64 | =head1 VERSION | ||||||||||
| 65 | |||||||||||
| 66 | version 1.1205 | ||||||||||
| 67 | |||||||||||
| 68 | =head1 SYNOPSIS | ||||||||||
| 69 | |||||||||||
| 70 | my $fb = Facebook::Graph->new( | ||||||||||
| 71 | secret => $facebook_application_secret, | ||||||||||
| 72 | app_id => $facebook_application_id, | ||||||||||
| 73 | postback => 'https://www.yourapplication.com/facebook/postback', | ||||||||||
| 74 | ); | ||||||||||
| 75 | |||||||||||
| 76 | my $uri = $fb->authorize | ||||||||||
| 77 | ->extend_permissions(qw( email publish_stream )) | ||||||||||
| 78 | ->set_display('popup') | ||||||||||
| 79 | ->uri_as_string; | ||||||||||
| 80 | |||||||||||
| 81 | =head1 DESCRIPTION | ||||||||||
| 82 | |||||||||||
| 83 | Get an authorization code from Facebook so that you can request an access token to make privileged requests. The result of this package is to give you a URI to redirect a user to Facebook so they can log in, and approve whatever permissions you are requesting. | ||||||||||
| 84 | |||||||||||
| 85 | =head1 METHODS | ||||||||||
| 86 | |||||||||||
| 87 | =head2 new ( [ params ] ) | ||||||||||
| 88 | |||||||||||
| 89 | =over | ||||||||||
| 90 | |||||||||||
| 91 | =item params | ||||||||||
| 92 | |||||||||||
| 93 | A hash or hashref of parameters to pass to the constructor. | ||||||||||
| 94 | |||||||||||
| 95 | =over | ||||||||||
| 96 | |||||||||||
| 97 | =item app_id | ||||||||||
| 98 | |||||||||||
| 99 | The application id that you get from Facebook after registering (L<http://developers.facebook.com/setup/>) your application on their site. | ||||||||||
| 100 | |||||||||||
| 101 | =item postback | ||||||||||
| 102 | |||||||||||
| 103 | The URI that Facebook should post your authorization code back to. | ||||||||||
| 104 | |||||||||||
| 105 | =back | ||||||||||
| 106 | |||||||||||
| 107 | =back | ||||||||||
| 108 | |||||||||||
| 109 | =head2 extend_permissions ( permissions ) | ||||||||||
| 110 | |||||||||||
| 111 | Ask for extra permissions for your app. By default, if you do not request extended permissions your app will have access to only general information that any Facebook user would have. Returns a reference to self for method chaining. | ||||||||||
| 112 | |||||||||||
| 113 | =head3 permissions | ||||||||||
| 114 | |||||||||||
| 115 | An array of permissions. See L<http://developers.facebook.com/docs/authentication/permissions> for more information about what's available. | ||||||||||
| 116 | |||||||||||
| 117 | |||||||||||
| 118 | =head2 uri_as_string ( ) | ||||||||||
| 119 | |||||||||||
| 120 | Returns a URI string to redirect the user back to Facebook. | ||||||||||
| 121 | |||||||||||
| 122 | |||||||||||
| 123 | |||||||||||
| 124 | =head1 LEGAL | ||||||||||
| 125 | |||||||||||
| 126 | Facebook::Graph is Copyright 2010 - 2017 Plain Black Corporation (L<http://www.plainblack.com>) and is licensed under the same terms as Perl itself. | ||||||||||
| 127 | |||||||||||
| 128 | =cut | ||||||||||