{"id":26091662,"url":"https://github.com/intercom/oauth2-intercom","last_synced_at":"2025-04-12T06:42:59.350Z","repository":{"id":10947078,"uuid":"67515822","full_name":"intercom/oauth2-intercom","owner":"intercom","description":"Intercom Provider for the OAuth 2.0 Client","archived":false,"fork":false,"pushed_at":"2023-02-21T17:36:34.000Z","size":16,"stargazers_count":7,"open_issues_count":2,"forks_count":6,"subscribers_count":150,"default_branch":"master","last_synced_at":"2025-04-12T06:42:52.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/intercom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-06T14:30:27.000Z","updated_at":"2025-03-25T13:16:11.000Z","dependencies_parsed_at":"2025-03-09T10:34:04.396Z","dependency_job_id":null,"html_url":"https://github.com/intercom/oauth2-intercom","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Foauth2-intercom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Foauth2-intercom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Foauth2-intercom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intercom%2Foauth2-intercom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intercom","download_url":"https://codeload.github.com/intercom/oauth2-intercom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530611,"owners_count":21119592,"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":[],"created_at":"2025-03-09T10:22:47.823Z","updated_at":"2025-04-12T06:42:59.321Z","avatar_url":"https://github.com/intercom.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intercom Provider for OAuth 2.0 Client\n\n[![Build Status](https://travis-ci.org/intercom/oauth2-intercom.svg?branch=master)](https://travis-ci.org/intercom/oauth2-intercom)\n\nThis package provides Intercom OAuth 2.0 support for the PHP League's [OAuth 2.0 Client](https://github.com/thephpleague/oauth2-client).\n\n## Installation\n\nTo install, use composer:\n\n```\ncomposer require intercom/oauth2-intercom\n```\n\n## Usage\n\nUsage is the same as The League's OAuth client, using `\\Intercom\\OAuth2\\Client\\Provider\\Intercom` as the provider.\n\n### Authorization Code Flow\n\n```php\n$provider = new Intercom\\OAuth2\\Client\\Provider\\Intercom([\n    'clientId'          =\u003e '{intercom-client-id}',\n    'clientSecret'      =\u003e '{intercom-client-secret}',\n    'redirectUri'       =\u003e 'https://example.com/callback-url'\n]);\n\nif (!isset($_GET['code'])) {\n\n    // If we don't have an authorization code then get one\n    $authUrl = $provider-\u003egetAuthorizationUrl();\n    $_SESSION['oauth2state'] = $provider-\u003egetState();\n    header('Location: '.$authUrl);\n    exit;\n\n// Check given state against previously stored one to mitigate CSRF attack\n} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {\n\n    unset($_SESSION['oauth2state']);\n    exit('Invalid state');\n\n} else {\n\n    // Get 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 token, you can look up a users profile data\n    try {\n\n        // We got an access token, let's now get the user's details\n        $user = $provider-\u003egetResourceOwner($token);\n\n        // Use these details to create a new profile\n        printf('Hello %s', $user-\u003egetName());\n\n    } catch (Exception $e) {\n\n        exit('Failed to get user details');\n    }\n\n    echo $token;\n\n}\n```\n\nBy default Intercom provider rejects users with unverified email addresses. User info will not be populated in that case. To disable this check add verifyEmail set to false to your config:\n\n```php\n$provider = new Intercom\\OAuth2\\Client\\Provider\\Intercom([\n    'clientId'          =\u003e '{intercom-client-id}',\n    'clientSecret'      =\u003e '{intercom-client-secret}',\n    'redirectUri'       =\u003e 'https://example.com/callback-url',\n    'verifyEmail'       =\u003e false\n]);\n```\n\n## Refreshing a Token\n\nIntercom's OAuth implementation does not use refresh tokens. Access tokens are valid until a user revokes access manually, or until an app deauthorizes itself.\n\n## Testing\n\n``` bash\n$ ./vendor/bin/phpunit\n```\n\n## License\n\nThe Apache 2 License. Please see [License File](https://github.com/intercom/oauth2-intercom/blob/master/LICENSE) for more information.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintercom%2Foauth2-intercom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintercom%2Foauth2-intercom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintercom%2Foauth2-intercom/lists"}