pinterex v0.2.3 Pinterex.Api.Auth
This module contains all the logic for using OAuth for making calls to the Pinterest API.
Summary
Functions
Use this method to get the authorization url. Redirect your user to this url so that the user can allow your application to access his data
After you get the code from Pinterest you can use this function to get the access token
Perform a request. See request/2
for available options
Perform a request using client function
Types
option :: {:method, Tesla.Env.method} | {:url, Tesla.Env.url} | {:query, Tesla.Env.query} | {:headers, Tesla.Env.headers} | {:body, Tesla.Env.body} | {:opts, Tesla.Env.opts}
Functions
Perform a DELETE request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.delete("/users")
delete(Tesla.Env.client, Tesla.Env.url) :: Tesla.Env.t
delete(Tesla.Env.url, [option]) :: Tesla.Env.t
Perform a DELETE request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.delete("/users")
iex> ExampleApi.delete("/users", query: [page: 1])
Perform a DELETE request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.delete("/users", query: [page: 1])
Perform a GET request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.get("/users")
get(Tesla.Env.client, Tesla.Env.url) :: Tesla.Env.t
get(Tesla.Env.url, [option]) :: Tesla.Env.t
Perform a GET request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.get("/users")
iex> ExampleApi.get("/users", query: [page: 1])
Perform a GET request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.get("/users", query: [page: 1])
Use this method to get the authorization url. Redirect your user to this url so that the user can allow your application to access his data.
Parameters
- scope: the scope of the access you wish to get. See Pinterest documenation to decide what scope is appropriate.
- redirect_uri: after the user gives you permission Pinterest will redirect to this uri. It will pass the authorization code as a parameter. The code is then used in the next step to get the access token.
- client_id: the client id of your Pinterest app.
Returns
The url to which you should redirect your user to let him give you permission to access his data.
After you get the code from Pinterest you can use this function to get the access token.
Parameters
- client_it: the client id of your Pinterest app.
- client_secret: the client secret of your Pinterest app.
- code: the code that you got in the previous step.
Returns
The function returns either:
- {:ok, token} if the token was successfully retrieved
- {:error, message} if the retrieval failed
Perform a HEAD request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.head("/users")
head(Tesla.Env.client, Tesla.Env.url) :: Tesla.Env.t
head(Tesla.Env.url, [option]) :: Tesla.Env.t
Perform a HEAD request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.head("/users")
iex> ExampleApi.head("/users", query: [page: 1])
Perform a HEAD request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.head("/users", query: [page: 1])
Perform a OPTIONS request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.options("/users")
options(Tesla.Env.client, Tesla.Env.url) :: Tesla.Env.t
options(Tesla.Env.url, [option]) :: Tesla.Env.t
Perform a OPTIONS request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.options("/users")
iex> ExampleApi.options("/users", query: [page: 1])
Perform a OPTIONS request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.options("/users", query: [page: 1])
Perform a PATCH request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.patch("/users", %{name: "Jon"})
patch(Tesla.Env.client, Tesla.Env.url, Tesla.Env.body) :: Tesla.Env.t
patch(Tesla.Env.url, Tesla.Env.body, [option]) :: Tesla.Env.t
Perform a PATCH request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.patch("/users", %{name: "Jon"})
iex> ExampleApi.patch("/users", %{name: "Jon"}, query: [scope: "admin"])
patch(Tesla.Env.client, Tesla.Env.url, Tesla.Env.body, [option]) :: Tesla.Env.t
Perform a PATCH request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.patch("/users", %{name: "Jon"}, query: [scope: "admin"])
Perform a POST request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.post("/users", %{name: "Jon"})
post(Tesla.Env.client, Tesla.Env.url, Tesla.Env.body) :: Tesla.Env.t
post(Tesla.Env.url, Tesla.Env.body, [option]) :: Tesla.Env.t
Perform a POST request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.post("/users", %{name: "Jon"})
iex> ExampleApi.post("/users", %{name: "Jon"}, query: [scope: "admin"])
post(Tesla.Env.client, Tesla.Env.url, Tesla.Env.body, [option]) :: Tesla.Env.t
Perform a POST request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.post("/users", %{name: "Jon"}, query: [scope: "admin"])
Perform a PUT request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.put("/users", %{name: "Jon"})
put(Tesla.Env.client, Tesla.Env.url, Tesla.Env.body) :: Tesla.Env.t
put(Tesla.Env.url, Tesla.Env.body, [option]) :: Tesla.Env.t
Perform a PUT request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.put("/users", %{name: "Jon"})
iex> ExampleApi.put("/users", %{name: "Jon"}, query: [scope: "admin"])
put(Tesla.Env.client, Tesla.Env.url, Tesla.Env.body, [option]) :: Tesla.Env.t
Perform a PUT request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.put("/users", %{name: "Jon"}, query: [scope: "admin"])
Perform a request. See request/2
for available options.
Perform a request using client function
Options:
:method
- the request method, one of [:head, :get, :delete, :trace, :options, :post, :put, :patch]:url
- either full url e.g. “http://example.com/some/path” or just “/some/path” if usingTesla.Middleware.BaseUrl
:query
- a keyword list of query params, e.g.[page: 1, per_page: 100]
:headers
- a keyworld list of headers, e.g.[{"content-type", "text/plain"}]
:body
- depends on used middleware:- by default it can be a binary
- if using e.g. JSON encoding middleware it can be a nested map
- if adapter supports it it can be a Stream with any of the above
:opts
- custom, per-request middleware or adapter options
Examples:
iex> ExampleApi.request(method: :get, url: "/users/path")
You can also use shortcut methods like:
iex> ExampleApi.get("/users/1")
or
iex> myclient |> ExampleApi.post("/users", %{name: "Jon"})
Perform a TRACE request.
See request/1
or request/2
for options definition.
Example
iex> ExampleApi.trace("/users")
trace(Tesla.Env.client, Tesla.Env.url) :: Tesla.Env.t
trace(Tesla.Env.url, [option]) :: Tesla.Env.t
Perform a TRACE request.
See request/1
or request/2
for options definition.
Example
iex> myclient |> ExampleApi.trace("/users")
iex> ExampleApi.trace("/users", query: [page: 1])