From 5edc976941a688a2e9914f198ea24e5472fe4c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sun, 4 Feb 2018 21:53:08 +0100 Subject: [PATCH] google.gmail: vocab needs some docs --- extra/google/gmail/gmail-docs.factor | 23 +++++++++++++++++++++++ extra/google/gmail/gmail.factor | 8 ++++---- 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 extra/google/gmail/gmail-docs.factor diff --git a/extra/google/gmail/gmail-docs.factor b/extra/google/gmail/gmail-docs.factor new file mode 100644 index 0000000000..459d1f5d53 --- /dev/null +++ b/extra/google/gmail/gmail-docs.factor @@ -0,0 +1,23 @@ +! Copyright (C) 2018 Björn Lindqvist. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax ; +IN: google.gmail + +ARTICLE: "google.gmail" "GMail Client" +"This vocab implements an api to GMail based on " { $vocab-link "oauth2" } "." +$nl +"To use the vocab, it first needs to be supplied the 'Client ID' and 'Client secret settings' using the " { $link configure-oauth2 } " vord:" +{ $unchecked-example + "\"client-id\" \"client-secret\" configure-oauth2" +} +"The settings can be found on Google's developer console at " { $url "https://console.developers.google.com" } ". Then the authenticated users labels can be listed using:" +{ $unchecked-example + "list-labels" +} +"Or to list the first message in the users inbox:" +{ $unchecked-example + "\"INBOX\" list-messages-by-label \"messages\" of" + "first \"id\" of { } get-messages" +} ; + +ABOUT: "google.gmail" diff --git a/extra/google/gmail/gmail.factor b/extra/google/gmail/gmail.factor index a5ff85235e..29b5d1fa5c 100644 --- a/extra/google/gmail/gmail.factor +++ b/extra/google/gmail/gmail.factor @@ -11,20 +11,20 @@ CONSTANT: token-uri "https://www.googleapis.com/oauth2/v4/token" CONSTANT: redirect-uri "urn:ietf:wg:oauth:2.0:oob" CONSTANT: gmail-scope-ro "https://www.googleapis.com/auth/gmail.readonly" -SYMBOL: access-token +SYMBOLS: access-token google-oauth2 ; : configure-oauth2 ( client-id client-secret -- ) [ auth-uri token-uri redirect-uri ] 2dip gmail-scope-ro { } - oauth2 boa oauth2 set ; + oauth2 boa google-oauth2 set ; : ensure-token ( -- ) access-token [ [ dup access-expired? [ - oauth2 get over refresh-flow update-tokens + google-oauth2 get over refresh-flow update-tokens ] when ] [ - oauth2 get console-flow + google-oauth2 get console-flow ] if* ] change ;