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 139-144
sub auth_by_code {
Link Here
|
139 |
return $self->get_return_page_from_koha_session; |
139 |
return $self->get_return_page_from_koha_session; |
140 |
} |
140 |
} |
141 |
|
141 |
|
|
|
142 |
=head2 auth_by_userid($userid, $password, $website_id, $authorization_name) |
143 |
|
144 |
To be called to check auth of patron using OverDrive Patron Authentication method |
145 |
This requires a SIP connection configured with OverDrive |
146 |
|
147 |
=cut |
148 |
|
149 |
sub auth_by_userid { |
150 |
my $self = shift; |
151 |
my $userid = shift or croak "No user provided"; |
152 |
my $password = shift; |
153 |
croak "No password provided" unless ($password || !C4::Context->preference("OverDrivePasswordRequired")); |
154 |
my $website_id = shift or croak "OverDrive Library ID not provided"; |
155 |
my $authorization_name = shift or croak "OverDrive Authname not provided"; |
156 |
|
157 |
my ($access_token, $access_token_type, $auth_token) |
158 |
= $self->client->auth_by_user_id($userid, $password, $website_id, $authorization_name); |
159 |
$access_token or die "Invalid OverDrive code returned"; |
160 |
$self->set_token_in_koha_session($access_token, $access_token_type); |
161 |
|
162 |
$self->koha_patron->set({overdrive_auth_token => $auth_token})->store; |
163 |
return $self->get_return_page_from_koha_session; |
164 |
} |
165 |
|
142 |
use constant AUTH_RETURN_HANDLER => "/cgi-bin/koha/external/overdrive/auth.pl"; |
166 |
use constant AUTH_RETURN_HANDLER => "/cgi-bin/koha/external/overdrive/auth.pl"; |
143 |
sub _return_url { |
167 |
sub _return_url { |
144 |
my $self = shift; |
168 |
my $self = shift; |
Lines 205-211
sub auth_by_saved_token {
Link Here
|
205 |
my $koha_patron = $self->koha_patron; |
229 |
my $koha_patron = $self->koha_patron; |
206 |
if (my $auth_token = $koha_patron->overdrive_auth_token) { |
230 |
if (my $auth_token = $koha_patron->overdrive_auth_token) { |
207 |
my ($access_token, $access_token_type, $new_auth_token) |
231 |
my ($access_token, $access_token_type, $new_auth_token) |
208 |
= $self->client->auth_by_token($auth_token); |
232 |
= $self->client->make_access_token_request(); |
209 |
$self->set_token_in_koha_session($access_token, $access_token_type); |
233 |
$self->set_token_in_koha_session($access_token, $access_token_type); |
210 |
$koha_patron->set({overdrive_auth_token => $new_auth_token})->store; |
234 |
$koha_patron->set({overdrive_auth_token => $new_auth_token})->store; |
211 |
return $access_token; |
235 |
return $access_token; |