{"id":18794554,"url":"https://github.com/effectra/third-party","last_synced_at":"2025-12-29T18:30:13.845Z","repository":{"id":168249977,"uuid":"643887979","full_name":"effectra/third-party","owner":"effectra","description":"Effectra\\ThirdParty is a PHP library that provides OAuth configuration and functionality for various third-party platforms such as LinkedIn, GitHub, Facebook, and Google. It simplifies the process of integrating with these platforms and accessing user data through OAuth authentication","archived":false,"fork":false,"pushed_at":"2024-01-19T21:44:32.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T16:34:03.833Z","etag":null,"topics":["authentication","facebook","github","google","http-client","linkedin","oauth","oauth2","php","third-party"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/effectra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-05-22T11:14:45.000Z","updated_at":"2024-07-06T17:59:40.000Z","dependencies_parsed_at":"2024-11-07T21:32:10.576Z","dependency_job_id":"10c490fc-8bbc-4b85-b858-c2e565a5faa1","html_url":"https://github.com/effectra/third-party","commit_stats":null,"previous_names":["effectra/third-party"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/third-party/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718694,"owners_count":19685795,"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":["authentication","facebook","github","google","http-client","linkedin","oauth","oauth2","php","third-party"],"created_at":"2024-11-07T21:29:46.166Z","updated_at":"2025-12-29T18:30:13.784Z","avatar_url":"https://github.com/effectra.png","language":"PHP","readme":"# Effectra ThirdParty Library\n\nEffectra\\ThirdParty is a PHP library that provides OAuth configuration and functionality for various third-party platforms such as LinkedIn, GitHub, Facebook, and Google. It simplifies the process of integrating with these platforms and accessing user data through OAuth authentication.\n\n## Features\n\n- Simplified OAuth configuration and authentication for third-party platforms.\n- Easy retrieval of access tokens and user information.\n- Supports multiple popular platforms like LinkedIn, GitHub, Facebook, and Google.\n\n## Installation\n\nYou can install the Effectra\\ThirdParty library via Composer. Run the following command in your project directory:\n\n```shell\ncomposer require effectra/third-party\n```\n\n## Usage\n\n### LinkedIn\n\nTo use the LinkedIn OAuth functionality, follow these steps:\n\n1. Create an instance of the `LinkedIn` class by providing your LinkedIn client ID, client secret, and optional redirect URL and scopes.\n\n```php\nuse Effectra\\ThirdParty\\LinkedIn;\n\n$linkedin = new LinkedIn('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_REDIRECT_URL', ['r_liteprofile', 'r_emailaddress']);\n```\n\n2. Generate the authorization URL to redirect the user for authentication:\n\n```php\n$authUrl = $linkedin-\u003egetAuthURL();\n```\n\n3. Redirect the user to the generated authorization URL. After successful authentication, LinkedIn will redirect the user back to the specified redirect URL with an authorization code.\n\n4. Exchange the authorization code for an access token:\n\n```php\n$code = $_GET['code']; // The authorization code obtained from the LinkedIn redirect\n$accessToken = $linkedin-\u003egetAccessToken($code);\n```\n\n5. Use the access token to retrieve user information:\n\n```php\n$user = $linkedin-\u003egetUser($accessToken);\n```\n\n### GitHub\n\nTo use the GitHub OAuth functionality, follow these steps:\n\n1. Create an instance of the `GitHub` class by providing your GitHub client ID, client secret, and optional redirect URL and scopes.\n\n```php\nuse Effectra\\ThirdParty\\GitHub;\n\n$github = new GitHub('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_REDIRECT_URL', ['user']);\n```\n\n2. Generate the authorization URL to redirect the user for authentication:\n\n```php\n$authUrl = $github-\u003egetAuthURL();\n```\n\n3. Redirect the user to the generated authorization URL. After successful authentication, GitHub will redirect the user back to the specified redirect URL with an authorization code.\n\n4. Exchange the authorization code for an access token:\n\n```php\n$code = $_GET['code']; // The authorization code obtained from the GitHub redirect\n$accessToken = $github-\u003egetAccessToken($code);\n```\n\n5. Use the access token to retrieve user information:\n\n```php\n$user = $github-\u003egetUser($accessToken);\n```\n\n### Facebook\n\nTo use the Facebook OAuth functionality, follow these steps:\n\n1. Create an instance of the `Facebook` class by providing your Facebook client ID, client secret, and optional redirect URL and scopes.\n\n```php\nuse Effectra\\ThirdParty\\Facebook;\n\n$facebook = new Facebook('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_REDIRECT_URL', ['email']);\n```\n\n2. Generate the authorization URL to redirect the user for authentication:\n\n```php\n$authUrl = $facebook-\u003egetAuthURL();\n```\n\n3. Redirect the user to the generated authorization URL. After successful authentication, Facebook will redirect the user back to the specified redirect URL with an authorization code.\n\n4. Exchange the authorization code for an access token:\n\n```php\n$code = $_GET['code']; // The authorization code obtained from the Facebook redirect\n$accessToken = $facebook-\u003egetAccessToken($code);\n```\n\n5\n\n. Use the access token to retrieve user information:\n\n```php\n$user = $facebook-\u003egetUser($accessToken);\n```\n\n### Google\n\nTo use the Google OAuth functionality, follow these steps:\n\n1. Create an instance of the `Google` class by providing your Google client ID, client secret, and optional redirect URL and scopes.\n\n```php\nuse Effectra\\ThirdParty\\Google;\n\n$google = new Google('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET', 'YOUR_REDIRECT_URL', ['profile', 'email']);\n```\n\n2. Generate the authorization URL to redirect the user for authentication:\n\n```php\n$authUrl = $google-\u003egetAuthURL();\n```\n\n3. Redirect the user to the generated authorization URL. After successful authentication, Google will redirect the user back to the specified redirect URL with an authorization code.\n\n4. Exchange the authorization code for an access token:\n\n```php\n$code = $_GET['code']; // The authorization code obtained from the Google redirect\n$accessToken = $google-\u003egetAccessToken($code);\n```\n\n5. Use the access token to retrieve user information:\n\n```php\n$user = $google-\u003egetUser($accessToken);\n```\n\n## OAuthServiceInterface\n\n\n\nThe `OAuthServiceInterface` is an interface that defines the contract for an OAuth service. It provides methods for retrieving configuration, authorization URL, access token, and user data from an OAuth service.\n\n### Usage\n\nTo use this interface, you need to create a class that implements it and provides the necessary functionality. Here's an example of how you can implement the `OAuthServiceInterface`:\n\n```php\n\u003c?php\n\nnamespace Effectra\\ThirdParty;\n\nclass MyOAuthService implements OAuthServiceInterface\n{\n    // Implement the getConfig() method\n    public function getConfig(): array\n    {\n        // Return the configuration array for the OAuth service\n    }\n\n    // Implement the getAuthURL() method\n    public function getAuthURL(): string\n    {\n        // Return the authorization URL for the OAuth service\n    }\n\n    // Implement the getAccessToken() method\n    public function getAccessToken(string $code): string\n    {\n        // Get the access token for the OAuth service using the authorization code\n    }\n\n    // Implement the getUser() method\n    public function getUser(string $token): ?array\n    {\n        // Get the user data from the OAuth service using the access token\n    }\n}\n```\n\nIn the above example, you need to replace the placeholder methods with your actual implementation based on the OAuth service you are integrating with.\n\n### Method Overview\n\n#### `getConfig(): array`\n\nThis method returns the configuration array for the OAuth service.\n\n#### `getAuthURL(): string`\n\nThis method returns the authorization URL for the OAuth service.\n\n#### `getAccessToken(string $code): string`\n\nThis method retrieves the access token for the OAuth service using the authorization code provided as a parameter.\n\n#### `getUser(string $token): ?array`\n\nThis method retrieves the user data from the OAuth service using the access token provided as a parameter. It returns an array containing user data or `null` if the operation is unsuccessful.\n\n\n## License\n\nThis library is open source and available under the [MIT License](LICENSE).\n\n## Contribution\n\nContributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.\n\n## Credits\n\nThis library is developed and maintained by Effectra. You can find more information about us on our website: [www.effectra.com](https://www.effectra.com/)\n\n## Contact\n\nFor any inquiries or questions, you can reach us at [info@effectra.com](mailto:info@effectra.com)\n\n---\n\nFeel free to modify and customize this README file according to your specific needs.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fthird-party","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fthird-party","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fthird-party/lists"}