0

Did anyone found a way to refresh a token with the Weibo api ?

I implemented an authentication on my website in order to get the user token but, in the JSON the API returns, there is no "refresh_token" field. Missing this information I can't refresh the token of my app users.

I need this token to be auto-refreshed once the user has been authenticated one time because I use it in a CRON job to get the feed of the registered user and save it in database.

I use the facebook sdk provided in Weibo documentation https://github.com/xiaosier/libweibo

And my authentication code look like that:

    $o = new SaeTOAuthV2( WEIBO_APP_API_APP_KEY , WEIBO_APP_API_SECRET );
    $code_url = $o->getAuthorizeURL( WEIBO_APP_CALLBACK_URL );
    $error_message = '';
    if (isset($_GET['code']) && empty($val)) {
      $keys = array();
      $keys['code'] = $_GET['code'];
      $keys['redirect_uri'] = WEIBO_APP_CALLBACK_URL;
      try {
              $token = $o->getAccessToken( 'code', $keys );
              //$token['refresh_token_at'] = strtotime('+2 week');
      } catch (OAuthException $e) {
              $error_message = pll__('There was a problem during connection process. Please try again or contact the website administrator');
      }
    }

The json that the API returns :

{
    "access_token": "2.00pxxxxxxxxxxxxxxxxxxxxxxx",
    "remind_in": "157679999",
    "expires_in": 157679999,
    "uid": "65xxxxxxx",
    "isRealName": "true"
}

Do I miss something in the API Documentation ? Or is this a particular implementation of the Oauth pattern where you've got to get your refresh token by another way ? I searched a lot in the documentation and can't find a clue about that.

There are something disturbing, the timestamps for remind_in and expires_in give the following date when converted to human readable date : 1974-12-30 23:59:59

  • Why not just get another token? Nothing stopping you and also read [how to ask](https:/stackoverflow.com/help/mcve) without much context on what the api has or assuming everyone knows this api you won't get much mileage – Mike Tung Mar 23 '18 at 14:53
  • There is not so much context to give as my question is related to a public API itself and to a basic feature of it (refreshing token in an Oauth2 API). Also, when i try to get another token the API always returns me the same token (I use my developper account to connect). – Paul Bonneau Mar 23 '18 at 15:42

0 Answers0