You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/index.rst
+29-20Lines changed: 29 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,11 @@ Welcome to gkeepapi's documentation!
13
13
14
14
import gkeepapi
15
15
16
+
# Obtain a master token for your account
17
+
master_token = '...'
18
+
16
19
keep = gkeepapi.Keep()
17
-
keep.login('user@gmail.com', 'password')
20
+
keep.authenticate('user@gmail.com', master_token)
18
21
19
22
note = keep.createNote('Todo', 'Eat breakfast')
20
23
note.pinned = True
@@ -32,34 +35,40 @@ Client Usage
32
35
33
36
All interaction with Google Keep is done through a :py:class:`Keep` object, which is responsible for authenticating, syncing changes and tracking modifications.
34
37
35
-
Logging in
36
-
----------
38
+
Authenticating
39
+
--------------
37
40
38
-
gkeepapi leverages the mobile Google Keep API. To do so, it makes use of:py:mod:`gpsoauth`, which requires passing in the username and password. This was necessary as the API we're using is restricted to Google applications (put differently, there is no way to enable it on the Developer Console)::
41
+
The client uses the (private) mobile Google Keep API. A valid OAuth token is generated via:py:mod:`gpsoauth`, which requires a master token for the account. These tokens are so called because they have full access to your account. Protect them like you would a password::
39
42
40
43
keep = gkeepapi.Keep()
41
-
keep.login('...', '...')
44
+
keep.authenticate('user@gmail.com', master_token)
42
45
43
-
To reduce the number of logins you make to the server, you can store the master token after logging in. Protect this like a password, as it grants full access to your account::
46
+
Rather than storing the token in the script, consider using your platform secrets store::
There is also a deprecated :py:meth:`Keep.login` method which accepts a username and password. This is discouraged (and unlikely to work), due to increased security requirements on logins::
57
+
58
+
keep.login('user@gmail.com', 'password')
59
+
60
+
Obtaining a Master Token
61
+
------------------------
62
+
63
+
Instructions can be found in the gpsoauth `documentation <https://github.com/simon-weber/gpsoauth#alternative-flow>`__. If you have Docker installed, the following one-liner prompts for the necessary information and outputs the token::
Note: Enabling TwoFactor and logging in via an app password is recommended.
58
67
59
68
Syncing
60
69
-------
61
70
62
-
gkeepapi automatically pulls down all notes after login. It takes care of refreshing API tokens, so there's no need to call :py:meth:`Keep.login` again. After making any local modifications to notes, make sure to call :py:meth:`Keep.sync` to update them on the server!::
71
+
gkeepapi automatically pulls down all notes after authenticating. It takes care of refreshing API tokens, so there's no need to call :py:meth:`Keep.authenticate` again. After making any local modifications to notes, make sure to call :py:meth:`Keep.sync` to update them on the server!::
63
72
64
73
keep.sync()
65
74
@@ -78,10 +87,10 @@ The initial sync can take a while, especially if you have a lot of notes. To mit
78
87
state = json.load(fh)
79
88
keep.restore(state)
80
89
81
-
You can also pass the state directly to the :py:meth:`Keep.login` and :py:meth:`Keep.resume` methods::
90
+
You can also pass the state directly to the :py:meth:`Keep.authenticate` and the (deprecated) :py:meth:`Keep.login` methods::
@@ -425,7 +434,7 @@ These timestamps are all read-only.
425
434
FAQ
426
435
===
427
436
428
-
1. I get a "NeedsBrowser", "CaptchaRequired" or "BadAuthentication" :py:class:`exception.LoginException` when I try to log in.
437
+
1. I get a "NeedsBrowser", "CaptchaRequired" or "BadAuthentication" :py:class:`exception.LoginException` when I try to log in. (Not an issue when using :py:meth:`Keep.authenticate`)
429
438
430
439
This usually occurs when Google thinks the login request looks suspicious. Here are some steps you can take to resolve this:
431
440
@@ -435,7 +444,7 @@ This usually occurs when Google thinks the login request looks suspicious. Here
435
444
4. Upgrading to a newer version of Python (3.7+) has worked for some people. See this `issue <https://gitlab.com/AuroraOSS/AuroraStore/issues/217#note_249390026>`__ for more information.
436
445
5. If all else fails, try testing gkeepapi on a separate IP address and/or user to see if you can isolate the problem.
437
446
438
-
2. I get a "DeviceManagementRequiredOrSyncDisabled" :py:class:`exception.LoginException` when I try to log in.
447
+
2. I get a "DeviceManagementRequiredOrSyncDisabled" :py:class:`exception.LoginException` when I try to log in. (Not an issue when using :py:meth:`Keep.authenticate`)
439
448
440
449
This is due to the enforcement of Android device policies on your G-Suite account. To resolve this, you can try disabling that setting `here <https://admin.google.com/AdminHome?hl=no#MobileSettings:section=advanced&flyout=security>`__.
0 commit comments