• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 13 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vkontakte OAuth2 Strategy for OmniAuth

OmniAuth VKontakte

Ruby Codacy Badge Gem Version Maintainability

This is the unofficial OmniAuth strategy for authenticating to VKontakte via OAuth. To use it, you'll need to sign up for an OAuth2 Application ID and Secret on the Vkontakte Developers Page.

SWUbanner

Installing

Add to your Gemfile:

gem 'omniauth-vkontakte'

Then bundle install

Usage

OmniAuth::Strategies::Vkontakte is simply a Rack middleware.

Here's a quick example, adding the middleware to a Rails app in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :vkontakte, ENV['VK_API_ID'], ENV['VK_API_SECRET']
end

See the example Sinatra app.

Configuring

You can configure several options, which you pass in to the provider method via a Hash:

  • scope: a comma-separated list of access permissions you want to request from the user. Read the Vkontakte docs for more details
  • display: the display context to show the authentication page. Valid options include page, popup and mobile.
  • lang: specifies the language. Optional options include ru, ua, be, en, es, fi, de, it.
  • image_size: defines the size of the user's image. Valid options include mini(50x50), bigger(100x100), bigger_x2(200x200), original(200x*) and original_x2(400x*). Default is mini.
  • info_fields: specify which fields should be added to AuthHash when getting the user's info. Value should be a comma-separated string as per http://vk.com/dev/fields.
  • redirect_url: URL where code will be passed. This URL shall be a part of the domain specified in application settings http://vk.com/dev/auth_sites.
  • https: 1 - allows you to receive https links to photos and other media. 0 - return an http links (the default).

Here's an example of a possible configuration:

use OmniAuth::Builder do
  provider :vkontakte, ENV['VKONTAKTE_KEY'], ENV['VKONTAKTE_SECRET'],
           scope: 'friends,audio,photos',
           display: 'popup',
           lang: 'en',
           https: 1,
           image_size: 'original'
end

Authentication Hash

Here's an example Auth Hash available in request.env['omniauth.auth']:

{"provider"=>"vkontakte",
 "uid"=>"1",
 "info"=>
  {"name"=>"Павел Дуров",
   "nickname"=>"",
   "first_name"=>"Павел",
   "last_name"=>"Дуров",
   "image"=>"http://cs7001.vk.me/c7003/v7003079/374b/53lwetwOxD8.jpg",
   "location"=>"Росiя, Санкт-Петербург",
   "urls"=>{"Vkontakte"=>"http://vk.com/durov"}},
 "credentials"=>
  {"token"=>
    "187041a618229fdaf16613e96e1caabc1e86e46bbfad228de41520e63fe45873684c365a14417289599f3",
   "expires_at"=>1381826003,
   "expires"=>true},
 "extra"=>
  {"raw_info"=>
    {"id"=>1,
     "first_name"=>"Павел",
     "last_name"=>"Дуров",
     "sex"=>2,
     "nickname"=>"",
     "screen_name"=>"durov",
     "bdate"=>"10.10.1984",
     "city"=>{"id"=>2, "title"=>"Санкт-Петербург"},
     "country"=>{"id"=>1, "title"=>"Росiя"},
     "photo"=>"http://cs7001.vk.me/c7003/v7003079/374b/53lwetwOxD8.jpg",
     "photo_big"=>"http://cs7001.vk.me/c7003/v7003736/3a08/mEqSflTauxA.jpg",
     "online"=>1,
     "online_app"=>"3140623",
     "online_mobile"=>1}}}

The precise information available may depend on the permissions which you request.

Supported Rubies

Tested with the following Ruby versions:

  • Ruby MRI (2.7.0+)
  • JRuby (9.3.0+)

Contributing

  1. Fork it (https://github.com/mamantoha/omniauth-vkontakte/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Copyright: 2011-2023 Anton Maminov ([email protected])

This library is distributed under the MIT license. Please see the LICENSE file.

More Repositories

1

crest

HTTP and REST client for Crystal
Crystal
234
star
2

zipstream

A command line tool that allows you to easily share files and directories over the network
Crystal
60
star
3

nanoid.cr

Crystal implementation of Nanoid, secure URL-friendly unique ID generator.
Crystal
41
star
4

http_proxy

A HTTP Proxy server and client written in Crystal
Crystal
39
star
5

shards-info

Source code of https://shards.info/
Crystal
38
star
6

humanize_time

Adds the humanize method to reports the approximate distance in time between two Time. humanize supports i18n translations too so it can be used in internationalized apps.
Crystal
23
star
7

vkontakte_client

VKontakte API Client for Ruby
Ruby
22
star
8

mpd_client

Simple Music Player Daemon library written entirely in Ruby
Ruby
16
star
9

cryMPD

A minimalistic web-based MPD client
Crystal
14
star
10

twitter-crystal

A library to access the Twitter API using Crystal
Crystal
14
star
11

uaenv

UaEnv - модуль для роботи з українським текстом в Ruby. Головна ціль UaEnv - полегшити розробку україномовних програм на Ruby
Ruby
11
star
12

crystal_mpd

Concurrent MPD client written in Crystal
Crystal
10
star
13

xml_converter

Create hashes from XML documents easily.
Crystal
8
star
14

time_zone

A helper to work with time zones in Crystal
Crystal
8
star
15

iso_codes

🌐 Lists of various ISO standards (ISO 3166-1 for countries and ISO 639-2 for languages) with translations for Crystal
Crystal
8
star
16

zci

Zendesk and Crowdin integration Command Line Interface (CLI)
Ruby
7
star
17

dotfiles

Shell
6
star
18

crystal-cmark-gfm

Minimal C bindings for parsing and rendering with cmark-gfm
Crystal
6
star
19

zendesk_help_center_api_client_rb

Zendesk Help Center REST API Client
Ruby
6
star
20

crystal-hunspell

Crystal bindings for Hunspell.
Crystal
6
star
21

lifecell_api

lifecell_api is used to interact with the lifecell API from Ruby
Ruby
6
star
22

foaas_client

A Crystal client for FOAAS - a modern, RESTful, scalable solution to the common problem of telling people to fuck off
Crystal
5
star
23

mongo-sinatra-admin

Web-based MongoDB admin interface written with Ruby and Sinatra
Ruby
5
star
24

detransport_ternopil_telegram

Public transport in Ternopil 🇺🇦
Crystal
5
star
25

bytes_ext

Byte Conversion Library for Crystal
Crystal
5
star
26

detransport_lviv_telegram

Public transport in Lviv 🇺🇦
Crystal
4
star
27

telegram_bot

Telegram Bot API Wrapper for Crystal 💎
Crystal
4
star
28

shards_spec

A shard.yml parser for the Crystal language
Crystal
3
star
29

resolv-crystal

A DNS resolver library written in Crystal
Crystal
3
star
30

http-client-digest_auth

An implementation of RFC 2617 Digest Access Authentication for Crystal
Crystal
2
star
31

crystal-exif

Crystal bindings for libexif
Crystal
2
star
32

rbtorstat

rbtorstat is a simple web page generator, written in Ruby, which shows status information about the rTorrent bittorrent client
Ruby
2
star
33

fci

Freshdesk and Crowdin integration Command Line Interface (CLI)
Ruby
2
star
34

time_duration

Provides a structured and convenient way to work with durations of time in the Crystal programming language
Crystal
2
star
35

air_alert_map_ua_wallpaper

A CLI tool for setting the Air Raid Alert Map of Ukraine as a desktop background
Crystal
2
star
36

ydokey

A simple command-line utility for Linux to convert key commands to raw keycodes which used in ydotool
Crystal
2
star
37

crystal-hidapi

A Crystal interface to HIDAPI library.
Crystal
2
star
38

matiuky_regexp

A collection of usefull regular expressions for matiuky
Ruby
2
star
39

crystal-bplist

Generate and parse Apple binary .plist files with Crystal
Crystal
1
star
40

i18n_plural_rules

Custom plural rules support for i18n.cr library.
Crystal
1
star
41

uz-api

A Ruby interface to the Ukrzaliznytsia API (http://booking.uz.gov.ua/)
Ruby
1
star
42

validates_nested_uniqueness

Library for validating nested uniqueness in Rails.
Ruby
1
star
43

time_by_example

Provides a Crystal implementation of Go-style time formatting by example.
Crystal
1
star