Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug token sync action #16

Merged
merged 5 commits into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ run-docker:
# runs extractor a compiled jar file as java app. Built via boot build
# command or make build-jar command.
run-jar:
java -Xmx1g -jar targetinsights/project.jar -d $(DATADIR)
java -Xmx1g -jar targetinsights/exinsights-0.0.1.jar -d $(DATADIR)

# runs extractor directly from boot ie runs as clojure program
run-boot:
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
- list accounts
- save account-id
- various fixes
### 3.7.0
- debug token sync action
9 changes: 9 additions & 0 deletions src/keboola/docker/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
(:parameters (apply load-config datadir))
)

(defn app-access-token [& datadir]
(let
[auth-info (get-in
(apply load-config datadir)
[:authorization :oauth_api :credentials])
app-secret (:#appSecret auth-info)
app-id (:appKey auth-info)]
(str app-id "|" app-secret)))

(defn user-credentials [& datadir]
(let
[data (get-in
Expand Down
5 changes: 5 additions & 0 deletions src/keboola/facebook/api/request.clj
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,8 @@
(apply concat (get-request access-token "me/adaccounts"
:query {:fields "account_id,id,business_name,name,currency"}
:version version)))

(defn debug-token [app-token input-token & {:keys [version]}]
(let [query {:access_token app-token :input_token input-token}
url (make-url "debug_token" version)]
(:body (client/GET url :query-params query :as :json))))
1 change: 1 addition & 0 deletions src/keboola/facebook/insights_extractor/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
(empty? credentials) (docker-runtime/user-error "Missing facebook credentials")
(empty? (:token credentials)) (docker-runtime/user-error "Missing facebook token"))
(case action
"debugtoken" (sync-actions/debug-token (docker-config/app-access-token datadir) credentials)
"accounts" (sync-actions/accounts credentials config)
"adaccounts" (sync-actions/adaccounts credentials config)
(treat #(run credentials parameters (docker-config/out-dir-path datadir))))))
Expand Down
6 changes: 6 additions & 0 deletions src/keboola/facebook/insights_extractor/sync_actions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
(let [token (:token credentials)
accounts (request/get-adaccounts token)]
(log (generate-string accounts))))

(defn debug-token [app-token credentials]
(let [input-token (:token credentials)
response-data (:data (request/debug-token app-token input-token))
result (dissoc response-data :app_id)]
(log (generate-string result))))