Browse Source

Rename feedly to feedlex for application env

pull/2/head
James Wheaton 5 years ago
parent
commit
e07793ae68
2 changed files with 13 additions and 13 deletions
  1. 4
    4
      config/dev.exs
  2. 9
    9
      lib/feedlex/auth.ex

+ 4
- 4
config/dev.exs View File

@@ -1,7 +1,7 @@
use Mix.Config

# whether or not the app runs in sandbox mode
config :feedly, sandbox: true
config :feedly, client_id: "sandbox"
config :feedly, client_secret: "4205DQXBAP99S8SUHXI3" # (expires on 6/1/2015)
config :feedly, redirect_uri: "http://localhost:8080/" # don't forget the closing "/"
config :feedlex, sandbox: true
config :feedlex, client_id: "sandbox"
config :feedlex, client_secret: "JSSBD6FZT72058P51XEG" # (expires on 4/1/2016)
config :feedlex, redirect_uri: "http://localhost:8080/" # don't forget the closing "/"

+ 9
- 9
lib/feedlex/auth.ex View File

@@ -16,8 +16,8 @@ defmodule Feedlex.Auth do
def authenticate_uri(opts \\ %{}) do
uri = Feedlex.feedly_api_host[opts[:env] || :sandbox] <> @feedly_auth_uri <> "?" <>
"response_type=#{opts[:response_type] || "code"}" <> "&" <>
"client_id=#{opts[:client_id] || Application.get_env(:feedly, :client_id)}" <> "&" <>
"redirect_uri=#{URI.encode_www_form(opts[:redirect_uri] || Application.get_env(:feedly, :redirect_uri))}" <> "&" <>
"client_id=#{opts[:client_id] || Application.get_env(:feedlex, :client_id)}" <> "&" <>
"redirect_uri=#{URI.encode_www_form(opts[:redirect_uri] || Application.get_env(:feedlex, :redirect_uri))}" <> "&" <>
"scope=#{opts[:scope] || "https://cloud.feedly.com/subscriptions"}"
unless is_nil(opts[:state]), do: uri = uri <> "&state=#{URI.encode_www_form(opts[:state])}"

@@ -32,15 +32,15 @@ defmodule Feedlex.Auth do
payload = ~s"""
{
"code":"#{opts[:code]}",
"client_id":"#{opts[:client_id] || Application.get_env(:feedly, :client_id)}",
"client_secret":"#{opts[:client_secret] || Application.get_env(:feedly, :client_secret)}",
"client_id":"#{opts[:client_id] || Application.get_env(:feedlex, :client_id)}",
"client_secret":"#{opts[:client_secret] || Application.get_env(:feedlex, :client_secret)}",
"state":"#{URI.encode_www_form(opts[:state] || "")}",
"grant_type":"#{opts[:grant_type] || "authorization_code"}"
}
"""

uri = Feedlex.feedly_api_host[opts[:env] || :sandbox] <> @feedly_auth_token_uri <> "?" <>
"redirect_uri=#{URI.encode_www_form(opts[:redirect_uri] || Application.get_env(:feedly, :redirect_uri))}"
"redirect_uri=#{URI.encode_www_form(opts[:redirect_uri] || Application.get_env(:feedlex, :redirect_uri))}"

HTTPoison.start
HTTPoison.post!(uri, payload, @request_headers_json)
@@ -54,8 +54,8 @@ defmodule Feedlex.Auth do
payload = ~s"""
{
"refresh_token":"#{opts[:refresh_token]}",
"client_id":"#{opts[:client_id] || Application.get_env(:feedly, :client_id)}",
"client_secret":"#{opts[:client_secret] || Application.get_env(:feedly, :client_secret)}",
"client_id":"#{opts[:client_id] || Application.get_env(:feedlex, :client_id)}",
"client_secret":"#{opts[:client_secret] || Application.get_env(:feedlex, :client_secret)}",
"grant_type":"refresh_token"
}
"""
@@ -74,8 +74,8 @@ defmodule Feedlex.Auth do
payload = ~s"""
{
"refresh_token":"#{opts[:refresh_token]}",
"client_id":"#{opts[:client_id] || Application.get_env(:feedly, :client_id)}",
"client_secret":"#{opts[:client_secret] || Application.get_env(:feedly, :client_secret)}",
"client_id":"#{opts[:client_id] || Application.get_env(:feedlex, :client_id)}",
"client_secret":"#{opts[:client_secret] || Application.get_env(:feedlex, :client_secret)}",
"grant_type":"revoke_token"
}
"""

Loading…
Cancel
Save