代码管理<br>
获取体验小程序的体验二维码
@since 2.8.9
@param access_token access_token
@return result
500134
public static GetQrcodeResult get_qrcode(String access_token){
		HttpUriRequest httpUriRequest = RequestBuilder.get()
								.setUri(BASE_URI + "/wxa/get_qrcode")
								.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
								.build();
		CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
		try {
			int status = httpResponse.getStatusLine().getStatusCode();
			Header header = httpResponse.getFirstHeader("Content-disposition");
			if(header != null && header.getValue().endsWith("filename=\"QRCode.jpg\"")){
				if(status == 200){
					byte[] bytes = EntityUtils.toByteArray(httpResponse.getEntity());
					GetQrcodeResult result = new GetQrcodeResult();
					result.setBufferedImage(ImageIO.read(new ByteArrayInputStream(bytes)));
					return result;
				}
			}else{
				String body = EntityUtils.toString(httpResponse.getEntity());
				return JsonUtil.parseObject(body, GetQrcodeResult.class);
			}
		} catch (IOException e) {
			logger.error("", e);
		} finally {
			try {
				httpResponse.close();
			} catch (IOException e) {
				logger.error("", e);
			}
		}
		return null;
	}
857126
def access_token_response(self, access_token):
        

        response_data = {
            'access_token': access_token.token,
            'token_type': constants.TOKEN_TYPE,
            'expires_in': access_token.get_expire_delta(),
            'scope': ' '.join(scope.names(access_token.scope)),
        }

        # Not all access_tokens are given a refresh_token
        # (for example, public clients doing password auth)
        try:
            rt = access_token.refresh_token
            response_data['refresh_token'] = rt.token
        except ObjectDoesNotExist:
            pass

        return HttpResponse(
            json.dumps(response_data), mimetype='application/json'
        )
942535
public function getAccessToken(string $session_token):AccessToken{

		$params = [
			'method'  => 'auth.getSession',
			'format'  => 'json',
			'api_key' => $this->options->key,
			'token'   => $session_token,
		];

		$params['api_sig'] = $this->getSignature($params);

		$request = $this->requestFactory
			->createRequest('GET', Psr7\merge_query($this->apiURL, $params));


		return $this->parseTokenResponse($this->http->sendRequest($request));
	}
659148
public function getAccessToken($access_token)
    {
        $token = $this->collection('access_token_table')->findOne(array('access_token' => $access_token));
        return is_null($token) ? false : $token;
    }
360765
protected Pair<AccessToken, RefreshToken> generateAccessTokenOAuthGrantTypes(final AccessTokenRequestDataHolder holder) {
        LOGGER.debug("Creating access token for [{}]", holder.getService());
        val clientId = holder.getRegisteredService().getClientId();
        val authn = DefaultAuthenticationBuilder
            .newInstance(holder.getAuthentication())
            .addAttribute(OAuth20Constants.GRANT_TYPE, holder.getGrantType().toString())
            .addAttribute(OAuth20Constants.SCOPE, holder.getScopes())
            .addAttribute(OAuth20Constants.CLIENT_ID, clientId)
            .build();

        LOGGER.debug("Creating access token for [{}]", holder);
        val ticketGrantingTicket = holder.getTicketGrantingTicket();
        val accessToken = this.accessTokenFactory.create(holder.getService(),
            authn, ticketGrantingTicket, holder.getScopes(), clientId);

        LOGGER.debug("Created access token [{}]", accessToken);
        addTicketToRegistry(accessToken, ticketGrantingTicket);
        LOGGER.debug("Added access token [{}] to registry", accessToken);

        updateOAuthCode(holder);

        val refreshToken = FunctionUtils.doIf(holder.isGenerateRefreshToken(),
            () -> generateRefreshToken(holder),
            () -> {
                LOGGER.debug("Service [{}] is not able/allowed to receive refresh tokens", holder.getService());
                return null;
            }).get();

        return Pair.of(accessToken, refreshToken);
    }
823066
public static GetIndustryResult templateGet_industry(String access_token) {
        HttpUriRequest httpUriRequest = RequestBuilder.post()
                .setUri(BASE_URI + "/cgi-bin/template/get_industry")
                .addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
                .build();
        return LocalHttpClient.executeJsonResult(httpUriRequest, GetIndustryResult.class);
    }
126363
public function getAccessToken()
    {
        if (!empty($this->access_token)) {
            return $this->access_token;
        }
        $cache = $this->config->get('appid') . '_access_token';
        $this->access_token = Tools::getCache($cache);
        if (!empty($this->access_token)) {
            return $this->access_token;
        }
        // 处理开放平台授权公众号获取AccessToken
        if (!empty($this->GetAccessTokenCallback) && is_callable($this->GetAccessTokenCallback)) {
            $this->access_token = call_user_func_array($this->GetAccessTokenCallback, [$this->config->get('appid'), $this]);
            if (!empty($this->access_token)) {
                Tools::setCache($cache, $this->access_token, 7000);
            }
            return $this->access_token;
        }
        list($appid, $secret) = [$this->config->get('appid'), $this->config->get('appsecret')];
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
        $result = Tools::json2arr(Tools::get($url));
        if (!empty($result['access_token'])) {
            Tools::setCache($cache, $result['access_token'], 7000);
        }
        return $this->access_token = $result['access_token'];
    }
232516
public function getAccessToken($access_token)
    {
        $token = $this->getObjectByType('access_token_table',$access_token);

        return is_null($token) ? false : $token;
    }
470415
public function setAccessToken($access_token)
    {
        $key = array_search('access_token', $this->persistantMap);
        if ($key !== false) {
            $this->store->set('access_token', $access_token);
        }

        $this->access_token = $access_token;

        return $this;
    }
396437
public function checkOauth2AccessToken($accessToken, $openId)
    {
        $result = $this->httpGet(self::WECHAT_SNS_AUTH_URL . http_build_query([
            'access_token' => $accessToken,
            'openid' => $openId
        ]));
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
920697
def access_token(self):
        
        if self._cached_access_token is not None:
            return self._cached_access_token
        resp = self._request(endpoint='access_token', data={'grant_type': 'client_credentials', 'scope': 'basic user'},
                             auth=(self.api_username, self.api_key))
        self._cached_access_token = resp['access_token']
        return self._cached_access_token
332984
public static MaterialcountResult get_materialcount(String access_token){
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setUri(BASE_URI+"/cgi-bin/material/get_materialcount")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,MaterialcountResult.class);
	}
390681
protected function normalizeAccessToken($access_token) {
    if (!isset($access_token['token_type'])) {
      $access_token['token_type'] = 'Bearer';
    }
    if (!isset($access_token['expires_at']) && isset($access_token['expires_in'])) {
      $access_token['expires_at'] = $access_token['expires_in'] + $access_token['request_time'];
    }
    return $access_token;
  }
142070
private function cache(string $access_token = null)
    {
        if ($access_token) {
            $this->cache->set('wechat_access_token_'.$this->app_id, $access_token, 7140);

            return 0;
        } else {
            return $this->cache->get('wechat_access_token_'.$this->app_id);
        }
    }
1207493
public function getAccessToken($access_token)
    {
        $sql   = sprintf('SELECT * from %s where access_token = :access_token', $this->config['access_token_table']);
        $token = $this->fetch($sql, compact('access_token'));
        if ($token) {
            // convert date string back to timestamp
            $token['expires'] = strtotime($token['expires']);
        }

        return $token;
    }
134735
public function userinfo($access_token)
    {
        return $this->apiClient->get()
        ->userinfo()
        ->withHeader(new ContentType('application/json'))
        ->withHeader(new AuthorizationBearer($access_token))
        ->call();
    }
1254771
public static BaseResult barSet(String accessToken, BarSet barSet) {
        return barSet(accessToken, JsonUtil.toJSONString(barSet));
    }