{"id":16731269,"url":"https://github.com/rohit-chouhan/googleauth","last_synced_at":"2025-10-30T10:39:44.196Z","repository":{"id":200738382,"uuid":"706142667","full_name":"rohit-chouhan/GoogleAuth","owner":"rohit-chouhan","description":"Most Streamlined and User-Friendly PHP Library for Google OAuth 2.0 \u0026 3.0 Integration","archived":false,"fork":false,"pushed_at":"2023-10-27T13:37:36.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-17T10:57:36.726Z","etag":null,"topics":["access","auth","easy","google","token"],"latest_commit_sha":null,"homepage":"","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/rohit-chouhan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-17T11:39:41.000Z","updated_at":"2023-10-17T12:02:33.000Z","dependencies_parsed_at":"2023-10-27T14:35:12.693Z","dependency_job_id":null,"html_url":"https://github.com/rohit-chouhan/GoogleAuth","commit_stats":null,"previous_names":["rohit-chouhan/googleauth"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/rohit-chouhan/GoogleAuth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-chouhan%2FGoogleAuth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-chouhan%2FGoogleAuth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-chouhan%2FGoogleAuth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-chouhan%2FGoogleAuth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rohit-chouhan","download_url":"https://codeload.github.com/rohit-chouhan/GoogleAuth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rohit-chouhan%2FGoogleAuth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281793463,"owners_count":26562612,"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","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["access","auth","easy","google","token"],"created_at":"2024-10-12T23:36:28.156Z","updated_at":"2025-10-30T10:39:44.179Z","avatar_url":"https://github.com/rohit-chouhan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"  GoogleAuth PHP Library Documentation\n\nGoogleAuth PHP Library Documentation\n====================================\n\nIntroduction\n------------\n\nGoogleAuth is a PHP library developed by Rohit Chouhan for integrating Google OAuth authentication into your web applications. It simplifies the process of handling OAuth authorization, token generation, and user information retrieval.\n\nTable of Contents\n-----------------\n\n*   [Installation](#installation)\n*   [Usage](#usage)\n    *   [Initialization](#initialization)\n    *   [Setting Redirect URI](#setting-redirect-uri)\n    *   [Setting OAuth Scopes](#setting-oauth-scopes)\n    *   [Getting OAuth Login URL](#getting-oauth-login-url)\n    *   [Getting Access Token](#getting-access-token)\n    *   [Refresh Access Token](#refresh-access-token)\n    *   [Resetting Access Token](#resetting-access-token)\n    *   [Getting User Information](#getting-user-information)\n\nInstallation\n------------\n\nClone the repository from [GitHub](https://github.com/rohit-chouhan/GoogleAuth) or download the `GoogleAuth.php` file and include it in your project.\n\nUsage\n-----\n\n### Initialization\nThis function initializes the GoogleAuth class with the provided OAuth client ID and client secret.\n\n```php\n\u003c?php\n    session_start();\n    require_once('GoogleAuth.php');\n    \n    // Your OAuth client ID and client secret from Google Cloud Console\n    $clientID = 'YOUR_CLIENT_ID';\n    $clientSecret = 'YOUR_CLIENT_SECRET';\n    \n    $googleAuth = new GoogleAuth($clientID, $clientSecret);\n```    \n\n### Setting Redirect URI\nThis function sets the redirect URI for OAuth authorization. It should match the redirect URI registered in the Google Cloud Console.\n\n```php\n$redirectURI = 'YOUR_REDIRECT_URI';\n$googleAuth-\u003esetRedirectURI($redirectURI);\n```\n\n### Setting OAuth Scopes\nThis function sets the OAuth scopes required for authorization. It takes an array of OAuth scopes as a parameter.\n\n```php\n$scope = ['email', 'profile']; // Example scopes\n$googleAuth-\u003esetScope($scope);\n```  \n\n### Getting OAuth Login URL\nThis function generates the OAuth login URL. Users are redirected to this URL to authorize the application.\n\n```php\n$authURL = $googleAuth-\u003egetLoginURI();\n```   \n\n### Getting Access Token\nThis function returns the access token received after user login for an access token, you don't need to refresh your token, this function can refresh access token every time, so user don't need to login everytime.\n`$code` parameter is only required, when user authorize first time.\n```php\n$code = $_GET['code']; // Authorization code received after user login\n$accessToken = $googleAuth-\u003egetAccessToken($code);\n```  \n### Refresh Access Token\nThis function help you to refresh your access token, when your original token is expired.\nThis function is optinal to use, because its already implemente with `getAccessToken()`, if `getAccessToken` not able to refresh token, then use this function.\n\n```php\n$googleAuth-\u003erefreshToken(\"YOUR_REFRESH_TOKEN\");\n```\n\n### Resetting Access Token\nThis function resets the stored access token. It can be used to perform a debug login.\n\n```php\n$googleAuth-\u003eresetAccessToken();\n```  \n\n### Getting User Information\nThis function retrieves user information using the stored access token. It returns an object containing user details such as name and email address.\n\n```php\n$userInfo = $googleAuth-\u003egetUserInfo();\necho \"User Name: \" . $userInfo-\u003ename;\necho \"User Email: \" . $userInfo-\u003eemail;\n```\n\n### Complete Example Code\n```php\n\u003c?php\nsession_start();\n/** \n* Session start is required to save user token, so user don't need to login every time\n* this library can help you to refresh token automatically\n*/\n\n/**\n * Make sure this page is as your redirect URI\n * Ex. if this page is example.com/login.php same url should be in Redirect URL in Console Cloud\n */\n\ninclude \"GoogleAuth.php\";\n\n$clientID = \"\"; //Client ID Here\n$clientSecret = \"\"; //Client Secret Code Here\n$redirectURI = \"\"; //Registered Redirect URL Here\n$scope = [\"profile\", \"email\"]; //Scopes\n\n$google_auth = new GoogleAuth($clientID,$clientSecret);\n$google_auth-\u003esetRedirectURI($redirectURI);\n$google_auth-\u003esetScope($scope);\n\nif (isset($_GET['code'])) {\n    $code = $_GET['code'];\n    $userInfo = $google_auth-\u003egetUserInfo();\n    echo '\u003cimg src=\"'. $userInfo-\u003epicture.'\"/\u003e';\n    echo '\u003cbr\u003e\u003cbr\u003e';\n    echo \"Name: \" .  $userInfo-\u003ename;\n    echo '\u003cbr\u003e\u003cbr\u003e';\n    echo \"Email: \" .  $userInfo-\u003eemail;\n    echo '\u003cbr\u003e\u003cbr\u003e';\n    echo \"Access Token: \" . $google_auth-\u003egetAccessToken($code);\n} else {\n    echo \"\u003ch2\u003eLogin to Continue\u003c/h2\u003e\";\n    echo '\u003ca href=\"' . $google_auth-\u003egetLoginURI() . '\"\u003e\u003cimg src=\"https://developers.google.com/static/identity/images/btn_google_signin_dark_normal_web.png\"/\u003e\u003c/a\u003e';\n}\n\n```\n\nFor more details, refer to the [GoogleAuth GitHub Repository](https://github.com/rohit-chouhan/GoogleAuth).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohit-chouhan%2Fgoogleauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frohit-chouhan%2Fgoogleauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frohit-chouhan%2Fgoogleauth/lists"}