vk_auth
Version, currently main branch1 version
- main branchlatestAug 13, 2024
github.com/mamantoha/vk_auth
Crystal library for getting Vk Access Token without manually accessing vk.com website from the browser
Installation
# Add this to your shard.yml
dependencies:
vk_auth:
github: mamantoha/vk_auth
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
>= 1.0.0- License
- MIT
- Author
- Anton Maminov
Dependencies
Runtime Dependencies
- mechanize*github: Kanezoh/mechanize.cr, branch: master
Development Dependencies
- vcr*github: spoved/vcr.crdev
README
Vk:Auth
Crystal library for getting an Access Token without manually accessing vk.com website from the browser.
access_token is needed to run most Vk API requests.
Installation
-
Add the dependency to your
shard.yml:dependencies: vk_auth: github: mamantoha/vk_auth -
Run
shards install
Usage
require "vk_auth"
Getting a Token
This library supports the Implicit flow way to obtain an OAuth 2.0 access token.
The Vk::Auth constructor takes one argument - the Vk application ID.
client = Vk::Auth.new(client_id)
The #get_token method takes the following arguments:
email: user loginpassword: user passwordpermissions: request application permissions
client.get_token(email, password, permissions: ["friends"])
After successful authorization, you can access #access_token:
if client.authorized?
client.access_token # => NamedTuple(access_token: String, expires_in: String, user_id: String)
access_token = client.token.not_nil!["access_token"]
end
API requests
Note, this shard doesn't provide the functionality to make API requests.
You can use previously obtained access_token to make API requests.
For example:
require "http/client"
access_token = "user-access-token"
method_name = "users.get"
parameters = "fields=bdate,city,country"
version = "5.131"
lang = "en"
url = "https://api.vk.com/method/#{method_name}?#{parameters}&access_token=#{access_token}&v=#{version}&lang=#{lang}"
resp = HTTP::Client.get(url)
Contributing
- Fork it (https://github.com/mamantoha/vk_auth/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Anton Maminov - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Aug 13, 2024
- Crystal
>= 1.0.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/mamantoha/vk_auth
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 15, 2026
- Versions
- 1