获取微信公众号授权用户唯一标识
@param $app_id 微信公众号应用唯一标识
@param $app_secret 微信公众号应用密钥（注意保密）
@param $code 授权code, 通过调用WxpubOAuth::createOauthUrlForCode来获取
@return openid 微信公众号授权用户唯一标识, 可用于微信网页内支付
189119
public static function getOpenid($app_id, $app_secret, $code)
    {
        $url = WxpubOAuth::_createOauthUrlForOpenid($app_id, $app_secret, $code);
        $res = self::_getRequest($url);
        $data = json_decode($res, true);

        return $data['openid'];
    }
673817
public function vaildAccessToken(string $access_token, string $open_id)
    {
        $data = [
            'access_token' => $access_token,
            'openid' => $open_id,
        ];
        $url = self::WECHAT.'auth?'.http_build_query($data);
        $data = $this->curl->get($url);

        return Response::json($data);
    }
1189181
public function getOauthAuth($access_token,$openid){
        $result = $this->http_get(self::API_BASE_URL_PREFIX.self::OAUTH_AUTH_URL.'access_token='.$access_token.'&openid='.$openid);
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            } else
              if ($json['errcode']==0) return true;
        }
        return false;
    }
1146274
public static function getAppIdByApiKey($api_key)
    {
        if (empty($api_key)) {
            return null;
        }
        $cacheKey = 'apikey2appid:' . $api_key;
        try {
            return \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () use ($api_key){
                return App::whereApiKey($api_key)->firstOrFail()->id;
            });
        } catch (ModelNotFoundException $ex) {
            return null;
        }
    }
1119672
public static String getCodeUrl(String appid, String mch_id, String product_id, String partnerKey,
			boolean isToShortUrl) {
		String url = "weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXX&time_stamp=XXXXX&nonce_str=XXXXX";
		String timeStamp = Long.toString(System.currentTimeMillis() / 1000);
		String nonceStr = Long.toString(System.currentTimeMillis());
		Map<String, String> packageParams = new HashMap<String, String>();
		packageParams.put("appid", appid);
		packageParams.put("mch_id", mch_id);
		packageParams.put("product_id", product_id);
		packageParams.put("time_stamp", timeStamp);
		packageParams.put("nonce_str", nonceStr);
		String packageSign = PaymentKit.createSign(packageParams, partnerKey);
		String qrCodeUrl = PaymentKit.replace(url, "XXXXX", packageSign, appid, mch_id, product_id, timeStamp,
				nonceStr);
		if (isToShortUrl) {
			String shortResult = WxPayApi
					.toShortUrl(PaymentKit.buildShortUrlParasMap(appid, null, mch_id, null, qrCodeUrl, partnerKey));
			Map<String, String> shortMap = PaymentKit.xmlToMap(shortResult);
			String return_code = shortMap.get("return_code");
			if (PaymentKit.codeIsOK(return_code)) {
				String result_code = shortMap.get("result_code");
				if (PaymentKit.codeIsOK(result_code)) {
					qrCodeUrl = shortMap.get("short_url");
				}
			}
		}

		return qrCodeUrl;
	}
721002
public function setCredentials($appId, $secretKey)
    {
        $this->appId = $appId;
        $this->secretKey = $secretKey;
        return $this;
    }
93385
def authenticate_with_auth_code(authorization_code, redirect_uri)
      response = @oauth_connection.post do |req|
        req.url '/oauth/token'
        req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
        req.body = {:grant_type => 'authorization_code', :client_id => api_key, :client_secret => api_secret, :code => authorization_code, :redirect_uri => redirect_uri}
      end

      @oauth_token = OAuthToken.new(response.body)
      configure_oauth
      @oauth_token
    end
173275
BoxCreateAuthRequest createOAuth(String code, String clientId, String clientSecret) {
        BoxCreateAuthRequest request = new BoxCreateAuthRequest(mSession, getTokenUrl(), code, clientId, clientSecret);
        return request;
    }
510059
public static function create($statuscode,$remote_app_id, $last_response){

        $aLogs = ApiLogQuery::create()->findByRemoteAppId($remote_app_id);
        foreach($aLogs as $oLog){
            $oLog->delete();
        }

        $oApiLog = new ApiLog();
        $oApiLog->setRemoteAppId($remote_app_id);
        $oApiLog->setStatuscode($statuscode);
        $oApiLog->setLastResponse($last_response);
        $dt = new \DateTime();
        $oApiLog->setDtCall($dt);
        $oApiLog->save();
    }
1067063
public function getCredentialsByApplicationId($applicationId)
    {
        return $this->createCommand()
            ->setRequest(
                $this->client->get(Url::factory('application')->setQuery(array('applicationId' => $applicationId)))
            )
            ->setResponseClass('Maba\OAuthCommerceInternalClient\Entity\ApplicationPassword[]')
        ;
    }
1125785
public static PreAuthCode api_create_preauthcode(String component_access_token, String component_appid) {
        String postJsonData = String.format("{\"component_appid\":\"%1$s\"}",
                component_appid);
        HttpUriRequest httpUriRequest = RequestBuilder.post()
                .setHeader(jsonHeader)
                .setUri(BASE_URI + "/cgi-bin/component/api_create_preauthcode")
                .addParameter("component_access_token", API.componentAccessToken(component_access_token))
                .setEntity(new StringEntity(postJsonData, Charset.forName("utf-8")))
                .build();
        return LocalHttpClient.executeJsonResult(httpUriRequest, PreAuthCode.class);
    }
990212
public static function init($appid, $component_appid, $component_appsecret, $component_token, $encoding_aes_key, $authorizer_access_token, $apiurl = 'https://api.weixin.qq.com/', $cacheDriver = 'File')
    {
        self::$APP_ID                     = $appid;
        self::$COMPONENT_APPID            = $component_appid;
        self::$COMPONENT_APPSECRET        = $component_appsecret;
        self::$COMPONENT_TOKEN            = $component_token;
        self::$COMPONENT_ENCODING_AES_KEY = $encoding_aes_key;
        self::$AUTHORIZER_ACCESS_TOKEN    = $authorizer_access_token;
        self::$CACHE_DRIVER               = $cacheDriver;
        self::$API_URL                    = $apiurl;
    }
279148
def create_authorization_code(self, authorization_request, subject_identifier, scope=None):
        # type: (oic.oic.message.AuthorizationRequest, str, Optional[List[str]]) -> str
        

        if not self._is_valid_subject_identifier(subject_identifier):
            raise InvalidSubjectIdentifier('{} unknown'.format(subject_identifier))

        scope = ' '.join(scope or authorization_request['scope'])
        logger.debug('creating authz code for scope=%s', scope)

        authorization_code = rand_str()
        authz_info = {
            'used': False,
            'exp': int(time.time()) + self.authorization_code_lifetime,
            'sub': subject_identifier,
            'granted_scope': scope,
            self.KEY_AUTHORIZATION_REQUEST: authorization_request.to_dict()
        }
        self.authorization_codes[authorization_code] = authz_info
        logger.debug('new authz_code=%s to client_id=%s for sub=%s valid_until=%s', authorization_code,
                     authorization_request['client_id'], subject_identifier, authz_info['exp'])
        return authorization_code
1061531
public function getOauthAccessToken($appid)
    {
        $code = isset($_GET['code']) ? $_GET['code'] : '';
        if (empty($code)) {
            return false;
        }
        empty($this->component_access_token) && $this->getComponentAccessToken();
        if (empty($this->component_access_token)) {
            return false;
        }
        $url = "https://api.weixin.qq.com/sns/oauth2/component/access_token?appid={$appid}&code={$code}&grant_type=authorization_code&"
            . "component_appid={$this->component_appid}&component_access_token={$this->component_access_token}";
        $json = $this->parseJson(Tools::httpGet($url));
        if ($json !== false) {
            return $json;
        }
        return false;
    }
529130
public static AuthcodetoopenidResult toolsAuthcodetoopenid(Authcodetoopenid authcodetoopenid,String key){
		Map<String,String> map = MapUtil.objectToMap(authcodetoopenid);
		String sign = SignatureUtil.generateSign(map,authcodetoopenid.getSign_type(),key);
		authcodetoopenid.setSign(sign);
		String shorturlXML = XMLConverUtil.convertToXML(authcodetoopenid);
		HttpUriRequest httpUriRequest = RequestBuilder.post()
				.setHeader(xmlHeader)
				.setUri(baseURI()+ "/tools/authcodetoopenid")
				.setEntity(new StringEntity(shorturlXML,Charset.forName("utf-8")))
				.build();
		return LocalHttpClient.executeXmlResult(httpUriRequest,AuthcodetoopenidResult.class,authcodetoopenid.getSign_type(),key);
	}
1168347
public function getOauthAuth($access_token, $openid)
    {
        $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_AUTH_URL . "access_token={$access_token}&openid={$openid}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                Tools::log("WechatOauth::getOauthAuth Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
                return false;
            } elseif (intval($json['errcode']) === 0) {
                return true;
            }
        }
        return false;
    }
1297324
def get_app_access_token
      return connection_params[:app_access_token] if connection_params.has_key? :app_access_token

      @oauth = Koala::Facebook::OAuth.new(connection_params[:app_id], connection_params[:app_secret], callback_url)
      connection_params[:app_access_token] = @oauth.get_app_access_token
    end