README.md

# WykopApi [![Hex pm](http://img.shields.io/hexpm/v/wykop_api.svg?style=flat)](https://hex.pm/packages/wykop_api)

Library for Wykop API

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:

  1. Add wykop_api to your list of dependencies in `mix.exs`:

        def deps do
          [{:wykop_api, "~> 0.0.1"}]
        end

  2. Ensure wykop_api is started before your application:

        def application do
          [applications: [:wykop_api]]
        end

## Configuration

Add following configuration in your `config/*.exs` file:

    config :wykop_api, :app,
      app_key: "",
      secret: ""

## Usage

Use `User.connect/1` to generate sign-in URL:

    iex(1)> WykopAPI.User.connect "http://12580f62.ngrok.com"
    "http://a.wykop.pl/user/connect/appkey,dqzvPmlYGO,redirect,aHR0cDovLzEyNTgwZjYyLm5ncm9rLmNvbQ==,secure,616e4cc7215368df328893d719ccbc0a"

Redirect users to sign-in URL. After they accept, they will be redirected to
`http://12580f62.ngrok.com?connectData=X`. Use `User.connect_callback/1` to
parse and validate `connectData`. If request is valid, you will receive
`%{login: login, token: account_key}`. You can use `account_key` to login
user with `User.login/1`.