#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use cPanelUserConfig; use LWP::Authen::OAuth2; use Data::Dumper; use strict; use warnings; our %data; require "incl/common.pl"; my $linkedin = LWP::Authen::OAuth2->new( client_id => 'xxxxxxxxxx', client_secret => 'xxxxxxxxxx', authorization_endpoint => 'https://api.linkedin.com/uas/oauth2/authorization', token_endpoint => 'https://api.linkedin.com/v2/accessToken', redirect_uri => "https://$ENV{'HTTP_HOST'}/cgi-bin/linkedin.pl?command=authorize_linkedin", scope => 'w_member_social', ); if ($data{'command'} eq 'linkedin') { my $auth_url = $linkedin->authorization_url; print "Location: $auth_url\n\n"; exit 0; } if ($data{'command'} eq 'authorize_linkedin') { print "Content-type: text-plain\n\n"; my $token = $linkedin->request_tokens( code => $data{'code'}, ); print "TOKEN: $token\n"; } print<<"END_HTML"; Content-type: text/html END_HTML