Skip to main content

Django app for developing vk.com (aka vkontakte.ru) iframe applications

Project description

Django app for developing vk.com (aka vkontakte.ru largest, Russian social network) iframe applications.

Handles user authentication and registration.

Installation

$ pip install django-vkontakte-iframe

Requirements

  • django-annoying for AutoOneToOneField

Optional:

  • vkontakte >= 0.9.4.1 for populating cities and countries info via admin action

  • django-webtest >= 1.2.2 for tests

Usage

  1. Register and configure vkontakte iframe application here: http://vkontakte.ru/apps.php?act=add

  2. Add your app’s settings to settings.py:

    VK_APP_ID = '1234567'                   # Application ID
    VK_APP_KEY = 'M1gytuHwni'               # Application key
    VK_APP_SECRET = 'MiRFwrDYwcYFCTD18EcY'  # Secure key
  3. Add ‘vk_iframe’ to INSTALLED_APPS

  4. Add ‘vk_iframe.backends.VkontakteUserBackend’ to AUTHENTICATION_BACKENDS:

    AUTHENTICATION_BACKENDS = (
        'django.contrib.auth.backends.ModelBackend',
        'vk_iframe.backends.VkontakteUserBackend',
    )
  5. Put ‘vk_iframe.middleware.AuthenticationMiddleware’ and ‘vk_iframe.middleware.LoginRequiredMiddleware’ to the end of MIDDLEWARE_CLASSES:

    MIDDLEWARE_CLASSES = [
        # ...
        'vk_iframe.middleware.AuthenticationMiddleware',
        'vk_iframe.middleware.LoginRequiredMiddleware',
    ]

    Vkontakte visitors will be automatically registered and authorized as django users (username == vkontakte user id).

    LoginRequiredMiddleware is an optional. It returns 403 for all unauthorized requests with urls not listed in settings.PUBLIC_URLS. You should enable it for security reasons. Example of PUBLIC_URLS:

    PUBLIC_URLS = [
        '^admin/$',
        '^my-callback/',
    ]
  6. Run python ./manage.py syncdb (or python ./manage.py migrate vk_iframe if South is used)

  7. Optional: load initial geo data (cities and countries):

    python manage loaddata vk-geo
  8. If you want to store more user data then put the following line as the ‘First API request’ (‘Первый запрос к API’) option (in your app edit page at vkontakte.ru):

    method=getProfiles&uids={viewer_id}&format=json&v=3.0&fields=uid,first_name,last_name,nickname,domain,sex,bdate,city,country,timezone,photo,photo_medium,photo_big,has_mobile,rate,contacts,education
  9. That’s all. All your app’s visitors are now registered and authenticated django users. Additional profile data is available as user.vk_profile.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-vkontakte-iframe-0.1.tar.gz (30.6 kB view details)

Uploaded Source

File details

Details for the file django-vkontakte-iframe-0.1.tar.gz.

File metadata

File hashes

Hashes for django-vkontakte-iframe-0.1.tar.gz
Algorithm Hash digest
SHA256 d3757251cda6ca19f1ab40862597fb0bbab815beabc55e03de3c32a8205098a6
MD5 3a0def40a9c27318c0a8e3ab0a400576
BLAKE2b-256 20a931fe00f41bfd892dc46401d5dcf224189e1cfef6f2d92ccbff6cea1fe663

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page