{"id":18794545,"url":"https://github.com/effectra/third-party-ts","last_synced_at":"2025-12-29T18:30:13.253Z","repository":{"id":218125082,"uuid":"745675762","full_name":"effectra/third-party-ts","owner":"effectra","description":"Effectra\\ThirdParty is a TS 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:59:08.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-30T15:49:40.035Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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":"2024-01-19T21:10:57.000Z","updated_at":"2024-01-19T21:47:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"da6570dd-b13c-40fb-bfb3-1a9a708ba498","html_url":"https://github.com/effectra/third-party-ts","commit_stats":null,"previous_names":["effectra/third-party-ts"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Fthird-party-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/third-party-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718692,"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":[],"created_at":"2024-11-07T21:29:44.508Z","updated_at":"2025-12-29T18:30:13.193Z","avatar_url":"https://github.com/effectra.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Effectra ThirdParty Library\n\nEffectra\\ThirdParty is a TypeScript 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 npm. Run the following command in your project directory:\n\n```shell\nnpm install @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```typescript\nimport { LinkedIn } from '@effectra/third-party';\n\nconst 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```typescript\nconst authUrl = linkedin.getAuthURL();\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```typescript\nconst code = '...'; // The authorization code obtained from the LinkedIn redirect\nconst accessToken = await linkedin.getAccessToken(code);\n```\n\n5. Use the access token to retrieve user information:\n\n```typescript\nconst user = await linkedin.getUser(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```typescript\nimport { GitHub } from '@effectra/third-party';\n\nconst 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```typescript\nconst authUrl = github.getAuthURL();\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```typescript\nconst code = '...'; // The authorization code obtained from the GitHub redirect\nconst accessToken = await github.getAccessToken(code);\n```\n\n5. Use the access token to retrieve user information:\n\n```typescript\nconst user = await github.getUser(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```typescript\nimport { Facebook } from '@effectra/third-party';\n\nconst 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```typescript\nconst authUrl = facebook.getAuthURL();\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```typescript\nconst code = '...'; // The authorization code obtained from the Facebook redirect\nconst accessToken = await facebook.getAccessToken(code);\n```\n\n5. Use the access token to retrieve user information:\n\n```typescript\nconst user = await facebook.getUser(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```typescript\nimport { Google } from '@effectra/third-party';\n\nconst 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```typescript\nconst authUrl = google.getAuthURL();\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```typescript\nconst code = '...'; // The authorization code obtained from the Google redirect\nconst accessToken = await google.getAccessToken(code);\n```\n\n5. Use the access token to retrieve user information:\n\n```typescript\nconst user = await google.getUser(accessToken);\n```\n\n## OAuthServiceInterface\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```typescript\nclass MyOAuthService implements OAuthServiceInterface {\n    // Implement the methods defined in the interface\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(): any`\n\nThis method returns the configuration object for the OAuth service.\n\n#### `getAuthURL(): string`\n\nThis method returns the authorization URL for the OAuth service.\n\n#### `getAccessToken(code: string): Promise\u003cstring\u003e`\n\nThis method retrieves the access token for the OAuth service using the authorization code provided as a parameter.\n\n#### `getUser(token: string): Promise\u003cany | null\u003e`\n\nThis method retrieves the user data from the OAuth service using the access token provided as a parameter. It returns an object containing user data or `null` if the operation is unsuccessful.\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)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fthird-party-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Fthird-party-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Fthird-party-ts/lists"}