{"id":18790767,"url":"https://github.com/alexmasterov/oauth2-headhunter","last_synced_at":"2025-04-13T14:13:42.586Z","repository":{"id":56944652,"uuid":"74826994","full_name":"AlexMasterov/oauth2-headhunter","owner":"AlexMasterov","description":"HeadHunter.ru Provider for the OAuth 2.0 Client","archived":false,"fork":false,"pushed_at":"2018-02-13T03:33:22.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T14:13:38.333Z","etag":null,"topics":["league-oauth2","oauth2","oauth2-headhunter","oauth2-provider"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexMasterov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-26T13:20:33.000Z","updated_at":"2023-09-17T17:03:26.000Z","dependencies_parsed_at":"2022-08-21T02:40:24.712Z","dependency_job_id":null,"html_url":"https://github.com/AlexMasterov/oauth2-headhunter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexMasterov%2Foauth2-headhunter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexMasterov%2Foauth2-headhunter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexMasterov%2Foauth2-headhunter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexMasterov%2Foauth2-headhunter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexMasterov","download_url":"https://codeload.github.com/AlexMasterov/oauth2-headhunter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248724628,"owners_count":21151561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["league-oauth2","oauth2","oauth2-headhunter","oauth2-provider"],"created_at":"2024-11-07T21:13:39.219Z","updated_at":"2025-04-13T14:13:42.565Z","avatar_url":"https://github.com/AlexMasterov.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HeadHunter.ru Provider for OAuth 2.0 Client\n\n[![Latest Stable Version](https://poser.pugx.org/alexmasterov/oauth2-headhunter/v/stable)](https://packagist.org/packages/alexmasterov/oauth2-headhunter)\n[![License](https://img.shields.io/packagist/l/alexmasterov/oauth2-headhunter.svg)](https://github.com/AlexMasterov/oauth2-headhunter/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/AlexMasterov/oauth2-headhunter.svg)](https://travis-ci.org/AlexMasterov/oauth2-headhunter)\n[![Code Coverage](https://scrutinizer-ci.com/g/AlexMasterov/oauth2-headhunter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/AlexMasterov/oauth2-headhunter/?branch=master)\n[![Code Quality](https://scrutinizer-ci.com/g/AlexMasterov/oauth2-headhunter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/AlexMasterov/oauth2-headhunter/?branch=master)\n\nThis package provides [HeadHunter.ru](https://hh.ru) OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).\n\n## Installation\n\nThe suggested installation method is via [composer](https://getcomposer.org/):\n\n```sh\ncomposer require alexmasterov/oauth2-headhunter\n```\n\n## Usage\n\n### Configuration\n```php\n$provider = new AlexMasterov\\OAuth2\\Client\\Provider\\HeadHunter([\n    'clientId'     =\u003e '{client_id}',\n    'clientSecret' =\u003e '{client_secret}',\n    'redirectUri'  =\u003e '{redirect_uri}',\n    'state'        =\u003e '{state}',\n]);\n```\n\n### Authorization\n```php\nif (!empty($_GET['error'])) {\n    // Got an error, probably user denied access\n    exit('Got error: ' . $_GET['error']);\n}\n\nif (empty($_GET['code'])) {\n    // If we don't have an authorization code then get one\n    $provider-\u003eauthorize();\n}\n\n// Try to get an access token (using the authorization code grant)\n$token = $provider-\u003egetAccessToken('authorization_code', [\n    'code' =\u003e $_GET['code']\n]);\n\n// Optional: Now you have a token you can look up a users profile data\ntry {\n    // We got an access token, let's now get the owner details\n    $ownerDetails = $provider-\u003egetResourceOwner($token);\n\n    // Use these details to create a new profile\n    printf('Hello, %s!', $ownerDetails-\u003egetFirstName());\n} catch (\\Exception $e) {\n    // Failed to get user details\n    exit('Something went wrong: ' . $e-\u003egetMessage());\n}\n\n// Use this to interact with an API on the users behalf\necho $token-\u003eaccessToken;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexmasterov%2Foauth2-headhunter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexmasterov%2Foauth2-headhunter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexmasterov%2Foauth2-headhunter/lists"}