1 #### `Connection()` object
3 This is the object that is used by `diaspy`'s internals.
4 It is pushed around and used by various methods and other objects:
6 * `Post()` and `Conversation()` objects require it to authenticate and
8 * streams use it for getting their contents,
12 `Connection()` is the most low-level part of `diaspy` and provides
13 everything what is needed to talk to a pod.
15 However, using only `Connection()` would be hard and cumberstone so
16 there are other modules to aid you and you are strongly encouraged to
24 `Connection()` will not log you in unless you explicitly order it to
25 do so. Logging in with `Connection()` is done via `login()` method.
29 connection = diaspy.connection.Connection(pod='https://pod.example.com',
38 Authentication in Diaspora\* is done with *token*. It is a string
39 which is passed to pod with several requests to prove you are who you
42 `Connection` provides you with a method to fetch this token and perform
43 various actions on your account.
44 This method is called `_fetchtoken()`.
45 It will try to download a token for you.
47 Once a token is fetched there is no use for doing it again.
48 You can save time by using `get_token()` method.
49 It will check whether the token had been already fetched and reuse it.
50 This is especially useful on slow or unstable connections.
51 `get_token()` has an optional `fetch` argument (it is of `bool` type,
52 by default `False`) which will tell it to fetch new token if you find
55 However, recommended way of dealing with token is to use `repr()`
56 function on `Connection` object. This will allow of your programs to be
57 future-proof because if for any reason we will change the way in which
58 authorization is handled `get_token()` method may be gone -- `repr()`
61 Here is how you should create your auth flow:
63 connection = diaspy.connection.Connection(...)
66 token = repr(connection)
71 ##### Note for developers
73 If you want to write your own interface or client for D\*
74 `Connection()` is the only object you need.
78 ###### Manual for `diaspy`, written by Marek Marecki