{"id":20208568,"url":"https://github.com/dicrtarasov/yii2-google","last_synced_at":"2026-05-18T04:34:09.044Z","repository":{"id":37532206,"uuid":"206434002","full_name":"dicrtarasov/yii2-google","owner":"dicrtarasov","description":"Google API integration for Yii2","archived":false,"fork":false,"pushed_at":"2023-04-19T20:41:36.000Z","size":98,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T10:16:31.169Z","etag":null,"topics":["api","dicr","google","php","yii2"],"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/dicrtarasov.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-09-04T23:36:06.000Z","updated_at":"2021-06-04T20:13:33.000Z","dependencies_parsed_at":"2025-10-04T05:32:01.808Z","dependency_job_id":null,"html_url":"https://github.com/dicrtarasov/yii2-google","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/dicrtarasov/yii2-google","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dicrtarasov%2Fyii2-google","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dicrtarasov%2Fyii2-google/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dicrtarasov%2Fyii2-google/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dicrtarasov%2Fyii2-google/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dicrtarasov","download_url":"https://codeload.github.com/dicrtarasov/yii2-google/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dicrtarasov%2Fyii2-google/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278267706,"owners_count":25958914,"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-04T02:00:05.491Z","response_time":63,"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":["api","dicr","google","php","yii2"],"created_at":"2024-11-14T05:36:09.361Z","updated_at":"2025-10-04T05:32:26.846Z","avatar_url":"https://github.com/dicrtarasov.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google API Integration for Yii\n\n## Настройка компонента\n\n```php\n'components' =\u003e [\n    'google' =\u003e [\n        'class' =\u003e dicr\\google\\Google::class,\n        'clientConfig' =\u003e [\n            'client_id' =\u003e 'XXXXXXX.apps.googleusercontent.com',\n            'access_type' =\u003e 'offline',\n            'prompt' =\u003e 'select_account consent',\n            'client_secret' =\u003e 'XXXXXXXX', // для простой авторизации\n            'credentials' =\u003e 'xxx', // см. Client::setAuthConfig\n            'scopes' =\u003e [           // см. Client::setScopes\n                Google_Service_Sheets::SPREADSHEETS,\n                Google_Service_Sheets::DRIVE,\n                Google_Service_Sheets::DRIVE_FILE\n            ],\n            'include_granted_scopes' =\u003e true\n        ]\n    ]\n];\n```\n        \n## Проверка валидности текущего токена\n\n```php\nuse Google\\Client;\nuse yii\\helpers\\Url;\n\n/** @var dicr\\google\\Google $google */\n$google = Yii::$app-\u003eget('google');\n\n/** @var Client $client */\n$client = $google-\u003eclient;\n\n// попробуем обновить токен через refresh_token, если имеется\nif ($client-\u003eisAccessTokenExpired() \u0026\u0026 !empty($client-\u003egetRefreshToken())) {\n    $token = $client-\u003efetchAccessTokenWithRefreshToken();\n    if (!empty($token)) {\n        // сохраняем токен в сессии\n        $this-\u003emodule-\u003eapi-\u003esessionToken = $token;\n    }\n}\n    \n// если обновить не получилось, тогда переходим на страницу авторизации\nif ($client-\u003eisAccessTokenExpired()) {\n    // сохраняем адрес возврата\n    Yii::$app-\u003euser-\u003ereturnUrl = Url::current();\n\n    // настраиваем адрес обработчика кода ответа\n    $client-\u003esetRedirectUri(Url::to(['my-module/google-callback'], true));\n        \n    // отправляем пользователя на страницу авторизации\n    return $this-\u003eredirect($client-\u003ecreateAuthUrl(), 303);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdicrtarasov%2Fyii2-google","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdicrtarasov%2Fyii2-google","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdicrtarasov%2Fyii2-google/lists"}