Bod has asked for the wisdom of the Perl Monks concerning the following question:
Continuing from my previous discussion about connecting to LinkedIn - see Injecting a value into HTTP::Header
I have managed to authenticate with LinkedIn using LWP::Authen::OAuth2::ServiceProvider::LinkedIn which I am writing. This is used by LWP::Authen::OAuth2. LinkedIn doesn't obey the OAuth2 standard which is why there was a need to add extra information.
But now I am having difficulty posting anything to LinkedIn and I am getting an error from LWP::Authen::OAuth2
Can't call method "request" on an undefined value at /home/shoples1/perl5/lib/perl5/LWP/Authen/OAuth2.pm line 107.
I've looked at the source code of LWP::Authen::OAuth2 to try and see what I need to do differently to make this work. However, I cannot fathom how that module is supposed to work. Clearly, it does work and it is my understanding that is missing because it is a working module. But these two subroutines just seem to be calling each other:
Having gone through the authentication and obtained a token, I am trying to make a post using the following code. I am not expecting it to actually make a post yet but I was expecting to get an error from LinkedIn and not an error from Perl.sub request { my ($self, $request, @rest) = @_; return $self->access_token->request($self, $request, @rest); # <- +line 107 } sub access_token { my $self = shift; return $self->{access_token}; }
Can you help me understand what the two subroutines in LWP::Authen::OAuth2 are actually doing?my $params = { 'content' => { 'title' => 'Test Title', 'descrition' => 'Test message', }, }; my $res = $linkedin->post('https://api.linkedin.com/v2/shares', $param +s); if ($res) { print "Content-type: text/plain\n\n"; print $res; exit 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Subs calling themselves
by choroba (Cardinal) on May 07, 2021 at 12:51 UTC | |
by Bod (Parson) on May 07, 2021 at 21:41 UTC | |
|
Re: Subs calling themselves
by roboticus (Chancellor) on May 07, 2021 at 13:05 UTC | |
by Bod (Parson) on May 07, 2021 at 21:43 UTC |