]> gitweb.factorcode.org Git - factor.git/commitdiff
google.gmail: vocab needs some docs
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 4 Feb 2018 20:53:08 +0000 (21:53 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Sun, 4 Feb 2018 20:53:08 +0000 (21:53 +0100)
extra/google/gmail/gmail-docs.factor [new file with mode: 0644]
extra/google/gmail/gmail.factor

diff --git a/extra/google/gmail/gmail-docs.factor b/extra/google/gmail/gmail-docs.factor
new file mode 100644 (file)
index 0000000..459d1f5
--- /dev/null
@@ -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"
index a5ff85235efdc0835a5d18b55ecabef41f5ea17f..29b5d1fa5c304793908fa133c7625bc022a3f7d1 100644 (file)
@@ -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 ;