How to achieve authentication with Twitter in Kivy App without manual intervention

33 views
Skip to first unread message

Shoumik Das

unread,
May 1, 2020, 3:10:12 AM5/1/20
to Kivy users support

I am trying to build a simple kivy app for mobiles / desktops which uses Twitter to authenticate users at the login screen. I am using Tweepy with Python to authenticate the users.


The authentication process works fine when I run the code from command line. It generates a redirect url which I open in a browser to authenticate the user and then it generates a pin. The pin is copied and entered into the command line interface of the parent Python program as an input and the authentication process completes successfully.


Is there a way to copy the generated pin from the browser's html content and directly use it as an input in the program without any human intervention? This would enhance the user experience and people would not get confused as to what to do with the PIN. I was playing around with the weburl, urllib and htmlparser libraries in Python and was wondering if there any way to achieve this seamless behaviour?


I have also heard about something called "webview". Can that be used here? Is there any usage example that I can refer?


Please help.

Elliot Garbus

unread,
May 1, 2020, 7:59:45 AM5/1/20
to kivy-...@googlegroups.com

Have you looked at the requests library?

Requests lets you issue HTML commands, and parse the received HTML. 

 

https://requests.readthedocs.io/en/stable/

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/c9eb9e01-935b-4490-a5fb-239606f37951%40googlegroups.com.

 

Shoumik Das

unread,
May 1, 2020, 11:16:16 AM5/1/20
to Kivy users support
Hi Eliott,

Thank you for the link. I shall study it to see if it can be implemented in my desktop app.

On a different note in relation to Twitter authentication, let us assume that I manage to successfully implement Twitter authentication in my app. The user closes the app without logging off, which is what usually happens in Android or iOS devices. When the user opens the app next time, he should not have to re-authenticate himself and the app should work seamlessly as if he had never logged out.

How does Kivy manage user sessions? Or is there a simpler approach like the following:

1. Authenticate the user once using Twitter authentication.
2. Store the authenticated username in a flat file in the local device in encrypted format.
3. When the user launches the app next time, read the flat file and decrypt the last logged in username and launch the application as if the user has successfully re-authenticated himself.
4. If the user explicitly logs off, delete the flat file with last logged in username.

Please advise which approach I should take.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Robert Flatt

unread,
May 1, 2020, 1:21:52 PM5/1/20
to Kivy users support

Elliot Garbus

unread,
May 2, 2020, 8:55:55 AM5/2/20
to kivy-...@googlegroups.com

This might be a better question to ask at the Twitter API forum.  You could support and persistence method you want in Kivy.

The requests library supports persistent sessions.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/746b9a5a-01b5-4579-b50e-1221a1412e85%40googlegroups.com.

 

Shoumik Das

unread,
May 3, 2020, 1:35:55 AM5/3/20
to Kivy users support
Thanks, Eliott.
Reply all
Reply to author
Forward
0 new messages