Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 40 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ If you want to picture how Pocketeer might look, [Pixar's character](http://pixa

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

1. Add pocketeer to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:pocketeer, "~> 0.1.5"}]
end
```

2. Ensure pocketeer is started before your application:
```elixir
def application do
[applications: [:pocketeer]]
end
```
1. Add pocketeer to your list of dependencies in `mix.exs`:

```elixir
def deps do
[{:pocketeer, "~> 0.1.5"}]
end
```

2. Ensure pocketeer is started before your application:

```elixir
def application do
[applications: [:pocketeer]]
end
```

## Authentication

Expand All @@ -34,28 +36,31 @@ Your application should offer a page where users are redirected to after confirm

The following steps show how to use the consumer key to get an access token.

1. Fetch `request_token` from Pocket.
```elixir
{:ok, body} = Pocketeer.Auth.get_request_token(consumer_key, "http://yoursite.com")
#=> {:ok, %{"code" => "abcd", "state" => nil}}
request_token = body["code"]
#=> "abcd"
```

2. With this token, redirect the user to the authorization page of your application.
```elixir
# a helper function can be used to construct the url.
Pocketeer.Auth.authorize_url("abcd", "http://yoursite.com")
#=> "https://getpocket.com/v3/oauth/authorize?request_token=abcd&redirect_uri=http%3A%2F%2Fyoursite.com"
```

3. Get an `access_token` after the user accepts the authorization.
```elixir
{:ok, body} = Pocketeer.Auth.get_access_token(consumer_key, request_token)
#=> {:ok, %{"access_token" => "efgh", "username" => "pocketuser"}}
access_token = body["access_token"]
#=> "egfh"
```
1. Fetch `request_token` from Pocket.

```elixir
{:ok, body} = Pocketeer.Auth.get_request_token(consumer_key, "http://yoursite.com")
#=> {:ok, %{"code" => "abcd", "state" => nil}}
request_token = body["code"]
#=> "abcd"
```

2. With this token, redirect the user to the authorization page of your application.

```elixir
# a helper function can be used to construct the url.
Pocketeer.Auth.authorize_url("abcd", "http://yoursite.com")
#=> "https://getpocket.com/v3/oauth/authorize?request_token=abcd&redirect_uri=http%3A%2F%2Fyoursite.com"
```

3. Get an `access_token` after the user accepts the authorization.

```elixir
{:ok, body} = Pocketeer.Auth.get_access_token(consumer_key, request_token)
#=> {:ok, %{"access_token" => "efgh", "username" => "pocketuser"}}
access_token = body["access_token"]
#=> "egfh"
```

For more detailed handling of the request above:

Expand Down