LinkedIn API OAuth refresh token

I use the LinkedIn API to download updates and display on the website. When using OAuth, I save the token in a file and then pull it out again to prevent a login window from popping up. However, I do not understand, as soon as my token expires, how will it be updated. This is how I read the token from the file -

$config = json_decode(file_get_contents(".service.dat")); if( isset($config->key) && isset($config->secret) ) { $this->access_token = new OAuthConsumer($config->key, $config->secret); } 

For authentication, I have the following to get the request token -

 function getRequestToken() { $consumer = $this->consumer; $request = OAuthRequest::from_consumer_and_token($consumer, NULL, "GET", $this->request_token_path); $request->set_parameter("oauth_callback", $this->oauth_callback); $request->sign_request($this->signature_method, $consumer, NULL); $headers = Array(); $url = $request->to_url(); $response = $this->httpRequest($url, $headers, "GET"); parse_str($response, $response_params); $this->request_token = new OAuthConsumer($response_params['oauth_token'], $response_params['oauth_token_secret'], 1); } 

After generating the token, I generate url authorization:

 function generateAuthorizeUrl() { $consumer = $this->consumer; $request_token = $this->request_token; return $this->authorize_path . "?oauth_token=" . $request_token->key; } 

The LinkedIn documentation talks about the update token:

Updating the access token is very simple and can happen without the authorization dialog box opening for the user. In other words, it is a seamless process that does not affect the user experience of the application. Just ask your application to log in to receive a new access token with an additional 60-day lifespan.

I do not understand what it means. If I have to redo the entire path from receiving the request token, would it not be necessary for me to make an HTTP request again and I have to pop up the login screen? How to avoid this? Thank the suggestion.

Thanks.

+7
php oauth linkedin-api
source share
1 answer

Detected. Authorization URL:

https://www.linkedin.com/oauth/v2/authorization

followed by the URL of the access token:

https://www.linkedin.com/oauth/v2/accessToken

- that’s all I really needed to do (transition with the correct parameters).

+2
source share

All Articles