This is the object that is used by
It is pushed around and used by various methods and other objects:
Conversation()objects require it to authenticate and do their work,
Connection() is the most low-level part of
diaspy and provides
everything what is needed to talk to a pod.
However, using only
Connection() would be hard and cumberstone so
there are other modules to aid you and you are strongly encouraged to
Connection() will not log you in unless you explicitly order it to
do so. Logging in with
Connection() is done via
connection = diaspy.connection.Connection(pod='https://pod.example.com', username='user', password='password') connection.login()
Authentication in Diaspora* is done with token. It is a string which is passed to pod with several requests to prove you are who you are pretending to be.
Connection provides you with a method to fetch this token and perform
various actions on your account.
This method is called
It will try to download a token for you.
Once a token is fetched there is no use for doing it again.
You can save time by using
It will check whether the token had been already fetched and reuse it.
This is especially useful on slow or unstable connections.
get_token() has an optional
fetch argument (it is of
False) which will tell it to fetch new token if you find
However, recommended way of dealing with token is to use
Connection object. This will allow of your programs to be
future-proof because if for any reason we will change the way in which
authorization is handled
get_token() method may be gone --
Here is how you should create your auth flow:
connection = diaspy.connection.Connection(...) connection.login() token = repr(connection)
If you want to write your own interface or client for D*
Connection() is the only object you need.