当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::authenticate方法代码示例

本文整理汇总了PHP中Github\Client::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::authenticate方法的具体用法?PHP Client::authenticate怎么用?PHP Client::authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Github\Client的用法示例。


在下文中一共展示了Client::authenticate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 /**
  * Authenticates the current user for the upcoming API calls.
  */
 private function authenticate()
 {
     try {
         $this->client->authenticate($this->user->token, GitHubClient::AUTH_HTTP_TOKEN);
     } catch (\Exception $e) {
         \Bugsnag::notifyError('Exception', 'GitHub Authentication failed: ' . $e->getMessage());
     }
 }
开发者ID:cybercog,项目名称:gistvote,代码行数:11,代码来源:GitHub.php

示例2: __construct

 /**
  * @param string $apiToken
  */
 public function __construct($apiToken = '')
 {
     $this->apiToken = $apiToken;
     $this->client = new Client();
     if ($apiToken) {
         $this->client->authenticate($apiToken, null, Client::AUTH_HTTP_TOKEN);
     }
 }
开发者ID:ostretsov,项目名称:githubcmp,代码行数:11,代码来源:GithubRepositoryBuilder.php

示例3: __construct

 /**
  * @param string $token
  * @param Client $client
  */
 public function __construct($token = null, Client $client = null)
 {
     $this->client = $client ?: new Client(new CachedHttpClient());
     if ($token) {
         $this->client->authenticate($token, null, Client::AUTH_HTTP_PASSWORD);
     }
     parent::__construct();
 }
开发者ID:digitalkaoz,项目名称:issues,代码行数:12,代码来源:GithubTracker.php

示例4: getGithubClient

 /**
  * @return Client
  */
 public function getGithubClient()
 {
     if (!$this->client) {
         $token = $this->container->getParameter('github')['api']['auth_token'];
         $this->client = new \Github\Client();
         $this->client->authenticate($token, null, \Github\Client::AUTH_HTTP_TOKEN);
     }
     return $this->client;
 }
开发者ID:loopline-systems,项目名称:trello-github-issue-manager,代码行数:12,代码来源:GithubApi.php

示例5: __construct

 /**
  * コンストラクタ
  *
  * アクセストークンを利用して認証する
  *
  * @param string $access_token githubのアクセストークン
  * @param string $repo_owner   リポジトリのオーナー名
  * @param string $repo_name    リポジトリ名
  */
 public function __construct($access_token, $repo_owner, $repo_name)
 {
     $this->client = new \Github\Client();
     $this->client->authenticate($access_token, \Github\Client::AUTH_HTTP_TOKEN);
     $this->repo_owner = $repo_owner;
     $this->repo_name = $repo_name;
     $this->fh_pr = new JsonFile(sprintf(self::PR_SAVE_FILE_PATH_TPL, $repo_owner, $repo_name));
     $this->fh_comment = new JsonFile(sprintf(self::COMMENT_SAVE_FILE_PATH_TPL, $repo_owner, $repo_name));
 }
开发者ID:quelle,项目名称:Githutil,代码行数:18,代码来源:PRWatcher.php

示例6: login

 public function login(array $credentials)
 {
     $this->user = $credentials['user'];
     $this->repo = $credentials['repo'];
     $this->client = new Client();
     $this->client->authenticate($credentials['oauth_token'], Client::AUTH_HTTP_TOKEN);
     $this->checkLogin();
     return $this;
 }
开发者ID:JesusLeon,项目名称:Taskr,代码行数:9,代码来源:GithubApiRepository.php

示例7: createClient

 /**
  * @param string|null $accessToken
  * @return Client
  */
 public function createClient($accessToken = null)
 {
     $client = new Client();
     if ($this->token instanceof OAuthToken && null === $accessToken) {
         $client->authenticate($this->token->getAccessToken(), null, Client::AUTH_HTTP_TOKEN);
     } elseif (null !== $accessToken) {
         $client->authenticate($accessToken, null, Client::AUTH_HTTP_TOKEN);
     }
     return $client;
 }
开发者ID:approve-code,项目名称:approve-code-webapp,代码行数:14,代码来源:GithubClientFactory.php

示例8: init

 public function init()
 {
     parent::init();
     $this->api = new Client();
     if ($this->enterpriseUrl) {
         $this->api->setEnterpriseUrl($this->enterpriseUrl);
     }
     $this->api->authenticate($this->authKey, null, Client::AUTH_URL_TOKEN);
     //$this->repoInfo = $this->api->repository()->show($this->owner, $this->repository);
 }
开发者ID:bariew,项目名称:sitown,代码行数:10,代码来源:Github.php

示例9: __construct

 /**
  * @inheritdoc
  */
 public function __construct($token)
 {
     $cacheDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'snipper';
     // @codeCoverageIgnoreStart
     if (!is_dir($cacheDir)) {
         mkdir($cacheDir);
     }
     // @codeCoverageIgnoreEnd
     $this->client = new Client(new CachedHttpClient(['cache_dir' => $cacheDir]));
     $this->client->authenticate($token, Client::AUTH_HTTP_TOKEN);
 }
开发者ID:ssgonchar,项目名称:snipper,代码行数:14,代码来源:KnplabsClient.php

示例10: getClient

 /**
  * @return Client
  * @throws InvalidConfigurationException
  */
 protected function getClient()
 {
     if (!$this->client) {
         $this->client = $this->gitHubClientFactory->createClient();
         $token = $this->configProvider->getApiToken();
         if (empty($token)) {
             throw new InvalidConfigurationException('GitHub API token isn\'t set.');
         }
         $this->client->authenticate($token, null, Client::AUTH_URL_TOKEN);
     }
     return $this->client;
 }
开发者ID:rodolfobandeira,项目名称:training-crm-application,代码行数:16,代码来源:GitHubCollaboratorManager.php

示例11: authenticateClient

 /**
  * Authenticates github client
  */
 private function authenticateClient()
 {
     $fileName = $_SERVER['HOME'] . '/.gh/.gh.yml';
     if (file_exists($fileName) && ($content = file_get_contents($fileName))) {
         $config = Yaml::parse($content);
         $token = isset($config['parameters']['token']) ? $config['parameters']['token'] : null;
         if (null === $token) {
             return;
         }
         $this->client = new Client();
         $this->client->authenticate($token, null, Client::AUTH_HTTP_TOKEN);
         return;
     }
 }
开发者ID:peterrehm,项目名称:gh,代码行数:17,代码来源:Application.php

示例12: authenticate

 /**
  * @throws InvalidConfigurationException
  */
 public function authenticate()
 {
     $gitHubAccessToken = (string) Arrays::getValueByPath($this->gitHubSettings, 'contributor.accessToken');
     if (!$gitHubAccessToken) {
         throw new InvalidConfigurationException('The GitHub access token was not configured.', 1439627205);
     }
     $this->gitHubClient->authenticate($gitHubAccessToken, GithubClient::AUTH_HTTP_TOKEN);
     try {
         $userDetails = $this->gitHubClient->currentUser()->show();
         $this->currentUserLogin = $userDetails['login'];
     } catch (RuntimeException $exception) {
         throw new InvalidConfigurationException('It was not possible to authenticate to GitHub: ' . $exception->getMessage(), $exception->getCode());
     }
 }
开发者ID:kdambekalns,项目名称:Neos.Contribute,代码行数:17,代码来源:GitHubService.php

示例13: handleResponse

 public function handleResponse(UserResponseInterface $response, UserService $userService)
 {
     $fields = $response->getResponse();
     $gitHubLogin = $fields['login'];
     $accessToken = $response->getAccessToken();
     $user = $userService->findByGitHubLogin($gitHubLogin);
     if (null === $user) {
         throw new UsernameNotFoundException();
     }
     $oAuthUser = new OAuthUser($user);
     $oAuthUser->addRole('ROLE_GITHUB_USER');
     $oAuthUser->setAccessToken($accessToken);
     if (array_key_exists('name', $fields)) {
         $gitHubName = $fields['name'];
         $oAuthUser->setRealName($gitHubName);
     } else {
         $oAuthUser->setRealName($gitHubLogin);
     }
     $client = new Client();
     $client->setOption('api_version', 'v3');
     $client->authenticate($response->getAccessToken(), Client::AUTH_HTTP_TOKEN);
     /* @var \Github\Api\CurrentUser $currentUserApi */
     $currentUserApi = $client->api('current_user');
     $emails = $currentUserApi->emails();
     $allEMails = $emails->all();
     $oAuthUser->setEmail($this->getPrimaryEmailAddress($allEMails));
     return $oAuthUser;
 }
开发者ID:terretta,项目名称:gitki.php,代码行数:28,代码来源:GitHubResponseHandler.php

示例14: execute

 /**
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $changelog = array();
     $client = new Client(new \Github\HttpClient\CachedHttpClient(array('cache_dir' => '/tmp/github-api-cache')));
     $client->authenticate($input->getArgument("token"), null, Client::AUTH_HTTP_TOKEN);
     $pullRequestAPI = $client->api('pull_request');
     $paginator = new ResultPager($client);
     $parameters = array($input->getArgument("organisation"), $input->getArgument("repository"), array('state' => 'closed'));
     $pullRequests = $paginator->fetchAll($pullRequestAPI, 'all', $parameters);
     $mergedPullRequests = array_filter($pullRequests, function ($pullRequest) {
         return !empty($pullRequest["merged_at"]);
     });
     foreach ($mergedPullRequests as $pullRequest) {
         if (empty($pullRequest['milestone'])) {
             $milestone = "No Milestone Selected";
         } else {
             $milestone = $pullRequest['milestone']['title'] . " / " . strftime("%Y-%m-%d", strtotime($pullRequest['milestone']['due_on']));
         }
         if (!array_key_exists($milestone, $changelog)) {
             $changelog[$milestone] = array();
         }
         $changelog[$milestone][] = $pullRequest;
     }
     uksort($changelog, 'version_compare');
     $changelog = array_reverse($changelog);
     echo "# Changelog";
     foreach ($changelog as $milestone => $pullRequests) {
         echo "\n\n## {$milestone}\n\n";
         foreach ($pullRequests as $pullRequest) {
             echo "* " . $pullRequest['title'] . " [#" . $pullRequest['number'] . "](" . $pullRequest['html_url'] . ") ([@" . $pullRequest['user']['login'] . "](" . $pullRequest['user']['html_url'] . ")) \n";
         }
     }
     //var_dump($changelog);
 }
开发者ID:kunstmaan,项目名称:github-flow-changelog,代码行数:39,代码来源:ChangelogCommand.php

示例15: showPage

 public function showPage()
 {
     if (isset($_POST["register-data"]) && isset($_POST["register-password"])) {
         try {
             $client = new Client();
             $client->authenticate($_POST["register-data"], Client::AUTH_HTTP_TOKEN);
             $user = $client->api('current_user')->show();
             $repos = [];
             foreach ($client->api('current_user')->repositories('member', 'updated', 'desc') as $repo) {
                 $repos[] = ["name" => $repo["full_name"], "isPrivate" => $repo["private"]];
             }
             if (strlen($_POST["register-password"]) >= 6) {
                 Users::createUser($user["login"], $client->api('current_user')->emails()->all()[0], $_POST["register-password"], $_POST["register-data"], $repos);
                 Channels::addChannels($repos);
                 echo $this->getTemplateEngine()->render($this->getTemplateSnip("page"), ["title" => "Register", "content" => $this->getTemplateEngine()->render($this->getTemplate(), ["user" => $user])]);
             } else {
                 echo $this->getTemplateEngine()->render($this->getTemplateSnip("page"), ["title" => "Register", "content" => $this->getTemplateEngine()->render($this->getTemplate(), ["error" => "Passwords must be at least 6 characters long."])]);
             }
         } catch (\Exception $e) {
             echo $this->getTemplateEngine()->render($this->getTemplateSnip("page"), ["title" => "Register", "content" => $this->getTemplateEngine()->render($this->getTemplate(), ["error" => "Oh no! Your registration couldn't be completed. Do you already have an account? Is your token valid?"])]);
         }
     } else {
         echo $this->getTemplateEngine()->render($this->getTemplateSnip("page"), ["title" => "Register", "content" => $this->getTemplateEngine()->render($this->getTemplate(), [])]);
     }
     //echo $this->getTemplateEngine()->render($this->getTemplate(), []);
 }
开发者ID:xpyctum,项目名称:ShogChat,代码行数:26,代码来源:register.php


注:本文中的Github\Client::authenticate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。