a method to renew an access token from an oauth2 authorizing party

        :param auth_code: string with refresh token provided by service with access token
        :return: dictionary with access token details inside [json] key

        token_details = self.objects.token.schema

def renew_token(self, refresh_token):

        ''' a method to renew an access token from an oauth2 authorizing party

        :param auth_code: string with refresh token provided by service with access token
        :return: dictionary with access token details inside [json] key

        token_details = self.objects.token.schema
        '''

        title = '%s.renew_token' % self.__class__.__name__

    # validate inputs
        input_args = {
            'refresh_token': refresh_token
        }

        for key, value in input_args.items():
            if value:
                object_title = '%s(%s=%s)' % (title, key, value)
                self.fields.validate(value, '.%s' % key, object_title)

    # construct base url
        request_kwargs = {
            'url': self.token_endpoint
        }

    # construct token fields
        token_fields = {
            'grant_type': 'refresh_token',
            'refresh_token': refresh_token,
            'client_id': self.client_id,
            'client_secret': self.client_secret
        }

    # construct request params
        if self.request_mimetype == 'application/x-www-form-urlencoded':
            request_kwargs['data'] = token_fields
        elif self.request_mimetype == 'application/json':
            request_kwargs['json'] = token_fields
        else:
            request_kwargs['params'] = token_fields

    # send request
        from time import time
        current_time = time()
        token_details = self._post_request(**request_kwargs)

    # convert expiration info to epoch timestamp
        details = token_details['json']
        details['expires_at'] = 0
        if details:
            if 'expires_in' in details.keys():
                details['expires_at'] = int(current_time) + int(details['expires_in'])
                del details['expires_in']

        return token_details