回调页面.

@return array|mixed 返回用户基本信息

@example

<pre>
appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
<pre>
17909
public function callback()
    {
        $code = $_GET['code'] ?? null;
        $data = [
            'appid' => $this->app_id,
            'secret' => $this->app_secret,
            'code' => $code,
            'grant_type' => 'authorization_code',
        ];
        $url = self::ACCESS_TOKEN_URL.http_build_query($data);
        $data = json_decode($this->curl->get($url));

        if (property_exists($data, 'errcode')) {
            return (array) $data;
        }

        $access_token = $data->access_token;
        $expires_in = $data->expires_in;
        $refresh_token = $data->refresh_token;
        $open_id = $data->openid;
        $scope = $data->scope;

        if ('snsapi_base' === $scope) {
            return (array) $data;
        }
        $data = $this->getUserInfo($access_token, $open_id);

        return Response::json($data);
    }
432246
public function getMetaInfo()
    {
        if ($this->getAuthenticationDetails() instanceof AuthenticationDetails) {
            $authId     = $this->getAuthenticationDetails()->getAuthId();
            $authMethod = $this->getAuthenticationDetails()->getAuthMethod();
            $authRole   = $this->getAuthenticationDetails()->getAuthRole();
            $authRoles  = $this->getAuthenticationDetails()->getAuthRoles();
        } else {
            $authId     = 'anonymous';
            $authMethod = 'anonymous';
            $authRole   = 'anonymous';
            $authRoles  = [];
        }

        return [
            'realm'         => $this->getRealm()->getRealmName(),
            'authprovider'  => null,
            'authid'        => $authId,
            'authrole'      => $authRole,
            'authroles'     => $authRoles,
            'authmethod'    => $authMethod,
            'session'       => $this->getSessionId(),
            'role_features' => $this->getRoleFeatures()
        ];
    }
216120
public function new_access_token()
    {
        $url = self::API_DOMAIN . 'cgi-bin/token?grant_type=client_credential&appid=' . $this->appId . '&secret=' . $this->appSecret;
        $res = HttpCurl::get($url, 'json');

        // 异常处理: 获取access_token网络错误
        if ($res === false) {
            @error_log('Http Get AccessToken Error.', 0);
            return false;            
        }

        // 异常处理: access_token获取失败
        if (!isset($res->access_token)) {
            @error_log('Get AccessToken Error: ' . json_encode($res), 0);
            return false;
        }
        $res->expires_in += time();
        return $res;
    }
252897
public function getPreAuthCode()
    {
        $body = $this->parseJSON('json', [
            self::API_GET_COMPONENT_PRE_AUTHCODE,
            [
                'component_appid' => $this->getAccessToken()->getAppId()
            ]
        ]);

        //处理内容，返回预授权码
        return $body;
    }
1326747
public function getAccessToken()
    {
        if ($this->accessToken) {
            return $this->accessToken;
        }

        $cacheKey = $this->getAccessTokenCacheKey();
        $credential = $this->cache->get($cacheKey);

        if (!$credential || $credential['expireTime'] - time() < 60) {
            if (!$http = $this->getToken()) {
                return false;
            }

            $this->accessToken = $http['access_token'];
            $this->cache->set($cacheKey, [
                'accessToken' => $http['access_token'],
                'expireTime' => time() + $http['expires_in'],
            ]);
        } else {
            $this->accessToken = $credential['accessToken'];
        }

        return $this->accessToken;
    }
398614
public function getCategory()
    {
        if (!$this->access_token && !$this->getAccessToken()) {
            return false;
        }
        $result = Tools::httpGet(self::API_URL_PREFIX . self::POI_CATEGORY . "access_token={$this->access_token}");
        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'] : '无法解析接口返回内容！';
                return $this->checkRetry(__FUNCTION__, func_get_args());
            }
            return $json;
        }
        return false;
    }
122137
protected function getPageAccessDenied()
    {
        $this->debug('Controller and action changed to: ' . implode("/", $this->pageAccessDenied));
        $this->request()->setController($this->pageAccessDenied[0]);
        $this->request()->setAction($this->pageAccessDenied[1]);
        if (isset($this->pageAccessDenied[3]))
            $this->request()->setModule($this->pageAccessDenied[3]);
        if (isset($this->pageAccessDenied[2]) && is_string($this->pageAccessDenied[2]))
            $this->request()->setModule($this->pageAccessDenied[2]);
        elseif (isset($this->pageAccessDenied[2]) && is_array($this->pageAccessDenied[2]) && !empty($this->pageAccessDenied[2]))
            $this->request()->setParams($this->pageAccessDenied[2]);
        return $this->getControllerClassFromNameAndModule($this->pageAccessDenied[0], $this->request()->getModule());
    }
475790
protected function requestAppAccessToken()
    {
        $credentials = $this->authHelper->generateAppCredentials($this->apiKey, $this->apiSecret);

        $endpoint = '/oauth2/token';

        $url = $this->urlHelper->joinSlugs([$this->baseUrl, $endpoint]);

        $data = ['grant_type' => 'client_credentials'];

        $headers = [
            'Authorization' => 'Basic ' . $credentials,
            'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
        ];

        $response = $this->courier->post($url, $data, $headers)->toArray();

        return $response['access_token'];
    }
1077042
public function getAcceptedEncodings()
    {
        if (null === $this->encodings) {
            if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
                $this->encodings = strtolower(trim($_SERVER['HTTP_ACCEPT_ENCODING']));
            } else {
                $this->encodings = '';
            }
        }

        return $this->encodings;
    }
131648
public function queryAuth($authorization_code)
    {
        $params = array(
            'component_appid'    => $this->appid,
            'authorization_code' => $authorization_code,
        );

        return $this->http->jsonPost(self::API_QUERY_AUTH, $params);
    }
974140
public function getDepartments()
	{

		$me = Member::find($this->selfId)->department;

		$myDepartmentCode = Department::find($me)->code;

		$likeCode = $myDepartmentCode.'%';

		$recs = Department::where('code','LIKE', $likeCode)->get();

		if(count($recs)){
			$arr = [];
			foreach ($recs as $rec) {
				$arr = array_add($arr, $rec->id, $rec->name);
			}
			return $arr;
		}else{
			die('FooWeChat\Authorize\Auth\getDepartments: 记录异常');
			//return view('40x',['color'=>'danger', 'type'=>'1', 'code'=>'1.2']);
		}

	}
596674
public function getMerchantInfo()
    {
        $url = "https://api.weixin.qq.com/scan/merchantinfo/get?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpGetForJson($url);
    }
1366884
public function getAccessToken()
    {
        if (null === $this->accessTokens) {
            $this->accessTokens = [];
        }

        if (!array_key_exists($this->getRegion(), $this->accessTokens)) {
            $this->accessTokens[$this->getRegion()] = $this->requestAccessToken();
        }

        return $this->accessTokens[$this->getRegion()]->getToken();
    }
154734
public function getAccessToken()
    {
        if ($this->accessToken === null) {
            $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
            $content = array(
                'grant_type'     => 'assertion',
                'assertion_type' => 'http://oauth.net/grant_type/jwt/1.0/bearer',
                'assertion'      => $this->generateJsonWebToken(),
            );

            $response = json_decode($this->httpAdapter->postContent($this->url, $headers, $content));

            if (isset($response->error)) {
                throw GoogleAnalyticsException::invalidAccessToken($response->error);
            }

            $this->accessToken = $response->access_token;
        }

        return $this->accessToken;
    }
815913
public function getAuthLoginUrl()
    {
        $callback    = $this->getAuthCallbackUrl();
        $clientIdKey = $this->getClientIdKey();
        $clientSKey  = $this->getClientSecretKey();
        $state       = $this->getAuthLoginState();
        $url         = $this->getAuthenticationUrl()
            .'pages/'.$this->keys[$clientIdKey].'.json'
            .'?api_key='.$this->keys[$clientSKey]
            .'&response_type=code'
            .'&redirect_uri='.urlencode($callback)
            .'&state='.$state;

        if ($this->session) {
            $this->session->set($this->getName().'_csrf_token', $state);
        }

        return $url;
    }
547574
public function actionDocumentation()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;

        if ($this->apiDocsCacheEnabled) {
            $filename = str_replace('\\', '-', static::class);
            $path = Yii::getAlias($this->apiDocsCacheDirectory) . $filename . '.json';

            if (file_exists($path)) {
                $doc = file_get_contents($path);
            } else {
                $doc = $this->generator->getJson($this->version);
                // Store the credentials to disk.
                if (!is_dir(dirname($path))) {
                    mkdir(dirname($path), 0700, true);
                }
                file_put_contents($path, Json::encode($doc));
            }
        } else {
            $doc = $this->generator->getJson($this->version);
        }
        return $doc;
    }
428395
public function authenticate()
    {
        $result = false;

        if (isset($_GET['code'])) {
            $params = array(
                'grant_type' => 'authorization_code',
                'code' => $_GET['code'],
                'client_id' => $this->clientId,
                'client_secret' => $this->clientSecret
            );

            $tokenInfo = $this->post('https://oauth.yandex.ru/token', $params);

            if (isset($tokenInfo['access_token'])) {
                $params = array(
                    'format' => 'json',
                    'oauth_token' => $tokenInfo['access_token']
                );

                $userInfo = $this->get('https://login.yandex.ru/info', $params);

                if (isset($userInfo['id'])) {
                    $this->userInfo = $userInfo;
                    $result = true;
                }
            }
        }

        return $result;
    }