|
Lines 121-127
sub auth_url {
Link Here
|
| 121 |
|
121 |
|
| 122 |
=head2 auth_by_code($code, $base_url) |
122 |
=head2 auth_by_code($code, $base_url) |
| 123 |
|
123 |
|
| 124 |
To be called in external/overdrive/auth.pl upon return from OverDrive auth |
124 |
To be called in external/overdrive/auth.pl upon return from OverDrive Granted auth |
| 125 |
|
125 |
|
| 126 |
=cut |
126 |
=cut |
| 127 |
|
127 |
|
|
Lines 141-146
sub auth_by_code {
Link Here
|
| 141 |
return $self->get_return_page_from_koha_session; |
141 |
return $self->get_return_page_from_koha_session; |
| 142 |
} |
142 |
} |
| 143 |
|
143 |
|
|
|
144 |
=head2 auth_by_userid($userid, $password, $website_id, $authorization_name) |
| 145 |
|
| 146 |
To be called to check auth of patron using OverDrive Patron Authentication method |
| 147 |
This requires a SIP connection configured with OverDrive |
| 148 |
|
| 149 |
=cut |
| 150 |
|
| 151 |
sub auth_by_userid { |
| 152 |
my $self = shift; |
| 153 |
my $userid = shift or croak "No user provided"; |
| 154 |
my $password = shift; |
| 155 |
croak "No password provided" unless ($password || !C4::Context->preference("OverDrivePasswordRequired")); |
| 156 |
my $website_id = shift or croak "OverDrive Library ID not provided"; |
| 157 |
my $authorization_name = shift or croak "OverDrive Authname not provided"; |
| 158 |
|
| 159 |
my ($access_token, $access_token_type, $auth_token) |
| 160 |
= $self->client->auth_by_user_id($userid, $password, $website_id, $authorization_name); |
| 161 |
$access_token or die "Invalid OverDrive code returned"; |
| 162 |
$self->set_token_in_koha_session($access_token, $access_token_type); |
| 163 |
|
| 164 |
$self->koha_patron->set({overdrive_auth_token => $auth_token})->store; |
| 165 |
return $self->get_return_page_from_koha_session; |
| 166 |
} |
| 167 |
|
| 144 |
use constant AUTH_RETURN_HANDLER => "/cgi-bin/koha/external/overdrive/auth.pl"; |
168 |
use constant AUTH_RETURN_HANDLER => "/cgi-bin/koha/external/overdrive/auth.pl"; |
| 145 |
sub _return_url { |
169 |
sub _return_url { |
| 146 |
my $self = shift; |
170 |
my $self = shift; |
|
Lines 208-214
sub auth_by_saved_token {
Link Here
|
| 208 |
|
232 |
|
| 209 |
if (my $auth_token = $koha_patron->overdrive_auth_token) { |
233 |
if (my $auth_token = $koha_patron->overdrive_auth_token) { |
| 210 |
my ($access_token, $access_token_type, $new_auth_token) |
234 |
my ($access_token, $access_token_type, $new_auth_token) |
| 211 |
= $self->client->auth_by_token($auth_token); |
235 |
= $self->client->make_access_token_request(); |
| 212 |
$self->set_token_in_koha_session($access_token, $access_token_type); |
236 |
$self->set_token_in_koha_session($access_token, $access_token_type); |
| 213 |
$koha_patron->set({overdrive_auth_token => $new_auth_token})->store; |
237 |
$koha_patron->set({overdrive_auth_token => $new_auth_token})->store; |
| 214 |
return $access_token; |
238 |
return $access_token; |