@@ -19,13 +19,13 @@ To connect to a GitLab server, create a ``gitlab.Gitlab`` object:
19
19
20
20
import gitlab
21
21
22
- # private token authentication
22
+ # private token or personal token authentication
23
23
gl = gitlab.Gitlab(' http://10.0.0.1' , private_token = ' JVNSESs8EwWRx5yDxM5q' )
24
24
25
25
# oauth token authentication
26
26
gl = gitlab.Gitlab(' http://10.0.0.1' , oauth_token = ' my_long_token_here' )
27
27
28
- # username/password authentication
28
+ # username/password authentication (for GitLab << 10.2)
29
29
gl = gitlab.Gitlab(' http://10.0.0.1' , email = ' jdoe' , password = ' s3cr3t' )
30
30
31
31
# anonymous gitlab instance, read-only for public resources
@@ -44,6 +44,21 @@ You can also use configuration files to create ``gitlab.Gitlab`` objects:
44
44
See the :ref: `cli_configuration ` section for more information about
45
45
configuration files.
46
46
47
+ Note on password authentication
48
+ -------------------------------
49
+
50
+ The ``/session `` API endpoint used for username/password authentication has
51
+ been removed from GitLab in version 10.2, and is not available on gitlab.com
52
+ anymore. Personal token authentication is the prefered authentication method.
53
+
54
+ If you need username/password authentication, you can use cookie-based
55
+ authentication. You can use the web UI form to authenticate, retrieve cookies,
56
+ and then use a custom ``requests.Session `` object to connect to the GitLab API.
57
+ The following code snippet demonstrates how to automate this:
58
+ https://gist.github.com/gpocentek/bd4c3fbf8a6ce226ebddc4aad6b46c0a.
59
+
60
+ See `issue 380 <https://github.com/python-gitlab/python-gitlab/issues/380 >`_
61
+ for a detailed discussion.
47
62
48
63
API version
49
64
===========
0 commit comments