{"id":15017597,"url":"https://github.com/vodka2/vk-audio-token","last_synced_at":"2025-04-09T18:18:01.567Z","repository":{"id":38432195,"uuid":"142527864","full_name":"vodka2/vk-audio-token","owner":"vodka2","description":"Library that obtains VK tokens that work for VK audio API. Библиотека для получения токена VK, подходящего для Audio API.","archived":false,"fork":false,"pushed_at":"2023-01-06T21:39:24.000Z","size":7080,"stargazers_count":118,"open_issues_count":27,"forks_count":24,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-09T18:17:55.688Z","etag":null,"topics":["audio","music","vk","vkontakte"],"latest_commit_sha":null,"homepage":"https://vodka2.github.io/vk-audio-token/","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/vodka2.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-27T04:31:37.000Z","updated_at":"2025-03-17T17:30:06.000Z","dependencies_parsed_at":"2023-02-06T09:17:25.644Z","dependency_job_id":null,"html_url":"https://github.com/vodka2/vk-audio-token","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vodka2%2Fvk-audio-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vodka2%2Fvk-audio-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vodka2%2Fvk-audio-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vodka2%2Fvk-audio-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vodka2","download_url":"https://codeload.github.com/vodka2/vk-audio-token/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085328,"owners_count":21045139,"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":["audio","music","vk","vkontakte"],"created_at":"2024-09-24T19:50:43.864Z","updated_at":"2025-04-09T18:18:01.524Z","avatar_url":"https://github.com/vodka2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Library that obtains VK tokens that work for VK audio API\n\nRead this in [russian](README.ru.md).\n\nPython port of this library: [vodka2/vkaudiotoken-python](https://github.com/vodka2/vkaudiotoken-python)\n\nThis library obtains VK token, that works for VK audio API, so you can search artists, songs, albums, query audio URIs, add audios to \"My audios\" etc. The library supports Kate Mobile, Boom and VK Official clients. (Thanks to YTKABOBR for reversing the Boom client)\n\nActually there two versions of VK API, one for Kate Mobile and one for the official client. Boom client uses VK API somewhat similar to Kate one, but it has some limitations, not all methods are supported. Moreover it requires `messages` permission (do they scan our messages?) and sometimes returns 500 errors. On the other hand it supports another API in addition to VK API and may be used as a fallback.\n\n## Installation\n\n```\ncomposer require vodka2/vk-audio-token\n```\n\n... or simply copy the cloned repository somewhere and include `src/autoloader.php`. The library requires no dependencies.\n\n\n## Getting tokens\n\nThe simplest example:\n\n```php\n\u003c?php\n\nuse Vodka2\\VKAudioToken\\TokenFacade;\n\n$login = \"+71234567890\";\n$pass = \"12345\";\n\n// print token and User-Agent\n// setting User-Agent is mandatory when querying the API!\nvar_export(TokenFacade::getKateToken($login, $pass));\n```\n\nMore advanced examples are in the `examples` directory. Start with `example_simple.php`. \n\n## Using tokens\n\nThe simplest example:\n\n```php\n\u003c?php\n\ndefine('TOKEN', 'token from previous example');\ndefine('USER_AGENT', 'User-Agent from previous example');\n$ch = curl_init();\n\ncurl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: '.USER_AGENT));\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\n\ncurl_setopt(\n    $ch,\n    CURLOPT_URL,\n    \"https://api.vk.com/method/audio.getById?access_token=\".TOKEN.\n    \"\u0026audios=\".urlencode(\"371745461_456289486\").\n    \"\u0026v=5.95\"\n);\n\necho json_encode(json_decode(curl_exec($ch)), JSON_PRETTY_PRINT).\"\\n\\n\";\n```\n\nMore examples that show how to use obtained VK tokens with different API methods are in the `usage` subdirectory. More detailed VK API description is available at [https://vodka2.github.io/vk-audio-token/](https://vodka2.github.io/vk-audio-token/) (Currently in progress)\n\n## CLI tool\n\nThere is also more advanced CLI tool, that emulates Kate Mobile:\n```\nUsage: src/cli/vk-audio-token.php [options] vk_login vk_pass\n       src/cli/vk-audio-token.php [options] non_refreshed_kate_token\nOptions:\n-s file             - save GMS ID and token to the file\n-l file             - load GMS ID and token from file\n-g gms_id:gms_token - use specified GMS ID and token\n-d file             - use droidguard string from file\n                      instead of hardcoded one\n-m                  - make microG checkin (default)\n-o                  - old checkin with droidguard string\n                      that may expire\n                      with droidguard string is made\n-t code             - use two factor authentication\n                      pass GET_CODE to get code or\n                      pass code received in SMS\n-h                  - print this help\n```\n\n## Docker\n```\ndocker build -t vk-audio-tokens src/\ndocker run -t vk-audio-tokens:latest php src/cli/vk-audio-token.php -m vk_login vk_pass\ndocker run -t vk-audio-tokens:latest php src/examples/usage/example_kate.php token\n```\n\n## 2FA\n\nTwo factor authorization with SMS is supported for Kate and VK Official clients, however VK server sometimes does not send an SMS. If you don't receive it, you can use `TwoFAHelper` class to force resending. See `example_twofahelper.php`\n\nFor the Boom client the library uses implicit flow authorization and makes requests to the VK website. VK server may make a call, send an SMS or send private message to your VK account. You can also authenticate the client yourself and only pass the token and user id.\n\nIt is also possible to create separate passwords in VK account settings and use them instead of your account password.\n\n## GMS Credentials\n\nGMS credentials are also obtained while obtaining tokens. There are two ways to obtain GMS credentials.\n\nThe first way is to get them from a rooted Android device. The token is in `/data/data/com.google.android.gsf/shared_prefs/CheckinService.xml` file and ID is in `/data/data/com.google.android.gms/shared_prefs/Checkin.xml` file. You can install [GMS Credentials](https://github.com/vodka2/gms-credentials) application to see them.\n\nThe second way is to perform Android Checkin yourself. Class `AndroidCheckin` is designed for this task. This class provides two options: checkin with droidguard string and checkin as in [microG](https://github.com/microg) project. Note that the obtained credentials may expire.\n\nFor the first option you need a string that is generated by `com.google.ccc.abuse.droidguard` (the.apk). One such string is in `example_droidguard_str.php` file, it may expire. When using the second option one extra request is made and PHP needs to have sockets enabled.\n\nIt is also possible to intercept Android Checkin request (it is made on first boot) and see the returned GMS ID and token.\n\n## Buy me some healthy Russian drinks!\n\nWMR — P778046516389\n\nWMZ — Z828082159527\n\n[Yandex Money](https://money.yandex.ru/to/41001864186137)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvodka2%2Fvk-audio-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvodka2%2Fvk-audio-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvodka2%2Fvk-audio-token/lists"}