token 刷新后重试 post
420971
public static function post_retry($apiUrl, $data)
    {
        $urlarr = parse_url($apiUrl);
        parse_str($urlarr['query'], $parr);

        usleep(500000);

        $parr['access_token'] = self::getAccessToken();

        $apiUrl = $urlarr['scheme'] . '://' . $urlarr['host'] . $urlarr['path'];
        $apiUrl .= '?' . http_build_query($parr);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
        curl_setopt($ch, CURLOPT_URL, $apiUrl);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_NOBODY, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        $res      = trim(curl_exec($ch));
        $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        $header = '';
        $body   = $res;
        if ($httpcode == 200) {
            list($header, $body) = explode("\r\n\r\n", $res, 2);
            //list($header, $body) = explode("keep-alive", $res, 2);
            $header = self::http_parse_headers($header);
        }

        $result           = [];
        $result['info']   = $body;
        $result['header'] = $header;
        $result['status'] = $httpcode;

        $rest_retry = self::packData($result);
        if ($rest_retry === 'retry') {
            return false;
        }

        return $rest_retry;
    }
256112
def post(path, params = {})
      uri = URI.join(API_DOMAIN, path + "?access_token=#{token}")

      req = Net::HTTP::Post.new(uri)
      req.set_form_data(params)

      res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https|
        https.request(req)
      end
      JSON.parse(res.body)
    end
1095084
def post_update
      raise StateError.new 'device access_token prohibited' if @session.device?
      post_data = @data.dup
      post_data['tags'] = post_data.delete 'name'
      grok_self_from post 'tag/permissions/update', post_data
      self
    end
703044
def refresh_token(self):
        
        self.token = self.oauth.refresh_token(self.access_token_url, refresh_token=self.get_refresh_token())
        self.access_token = self.token.get("access_token")
559595
function setApiOpt(ctx, url, data, headers) {
    // 保存后端api配置
    ctx.__back__ = ctx.__back__ || {};

    ctx.__back__[url] = {
      url: url,
      data: data,
      headers: headers
    }

    return
  }
1106376
def replace_token(self, sid, sinfo, token_type):
        
        try:
            # Mint a new one
            refresh_token = self.handler[token_type](sid, sinfo=sinfo)
        except KeyError:
            pass
        else:
            # blacklist the old is there is one
            try:
                self.handler[token_type].black_list(sinfo[token_type])
            except KeyError:
                pass

            sinfo[token_type] = refresh_token

        return sinfo
576714
def update(self, params, path, **kwargs):
        
        self.client.request('POST', params, path, **kwargs)
1218271
def setUserPushTag(self, userTag):
        

        desc = {
            "name": "CodeSuccessReslut",
            "desc": " http 成功返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('API', 'POST', 'application/json'),
            action='/user/tag/set.json',
            params=userTag)
        return Response(r, desc)
664670
def post(self, request):
        ''''''
        serializer = CreateTokenSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        email = serializer.validated_data.get('email')
        password = serializer.validated_data.get('password')
        user = authenticate(username=email, password=password)
        if not user:
            return Response(status=status.HTTP_401_UNAUTHORIZED)

        Token.objects.filter(user=user).delete()
        token = Token.objects.create(user=user)

        return Response(
            status=status.HTTP_201_CREATED, data={'token': token.key})
162547
def create(self, ttl=values.unset):
        
        data = values.of({'Ttl': ttl, })

        payload = self._version.create(
            'POST',
            self._uri,
            data=data,
        )

        return TokenInstance(self._version, payload, account_sid=self._solution['account_sid'], )
68598
def refresh_token(self, subid):
    ''''''
    from expfactory.database.models import Participant
    p = Participant.query.filter(Participant.id == subid).first()
    if p is not None:
        p.token = str(uuid.uuid4())
    self.session.commit()
    return p
154107
def refresh_token(self, refresh_token, **kwargs):
        
        return self._token_request(grant_type='refresh_token',
                                   refresh_token=refresh_token, **kwargs)
490336
def post(self, request, *args, **kwargs):
        
        return self.update_type(request, *args, **kwargs)
1343826
def refresh(self, refresh_token):
        
        r = requests.post(self.apiurl + "/token", params={"grant_type": "refresh_token", "client_id": self.cid,
                                                          "client_secret": self.csecret,
                                                          "refresh_token": refresh_token})

        if r.status_code != 200:
            raise ServerError

        jsd = r.json()

        return jsd['access_token'], int(jsd['expires_in']) + int(jsd['created_at'])
557313
function() {

      var data, xhr;

      data = hashedit.retrieveUpdateArray();

      if (hashedit.saveUrl) {

        // construct an HTTP request
        xhr = new XMLHttpRequest();
        xhr.open('post', hashedit.saveUrl, true);

        // set token
        if(hashedit.useToken == true) {
          xhr.setRequestHeader(hashedit.authHeader, hashedit.authHeaderPrefix + ' ' + localStorage.getItem(hashedit.tokenName));
        }

        // send the collected data as JSON
        xhr.send(JSON.stringify(data));

        xhr.onloadend = function() {

          location.reload();

        };

      }

    }
1195919
def refresh(self, groupId, groupName):
        

        desc = {
            "name": "CodeSuccessReslut",
            "desc": " http 成功返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('API', 'POST', 'application/x-www-form-urlencoded'),
            action='/group/refresh.json',
            params={"groupId": groupId,
                    "groupName": groupName})
        return Response(r, desc)
210581
def post(self, uri, data, **kwargs):
        
        return self.request("POST", uri, data=data, **kwargs)