{ "info": { "author": "Dylan Fox", "author_email": "dylanbfox@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "# Simple Django Twitter Authentication\n\nSimple Django Twitter Authentication is an explicit, simple way to add \"Login with Twitter\" functionality to your Django project. The goal is to keep control in your hands, and to allow customization and implementation without having to dig through pages of documentation.\n\n## Installation\n\n1. `pip install simple-django-twitter-auth`\n\n2. Go to [https://apps.twitter.com](https://apps.twitter.com) and register an app if you haven't already\n\t- Make sure the \"Allow this application to be used to Sign in with Twitter\" option is enabled in your \"settings\" page!\n\n3. Grab your `API key` and `API secret` from your Twitter app dashboard\n\n4. Define the following settings in `settings.py`\n\n\t`TWITTER_APP_KEY = 'myappkey'` \n\t`TWITTER_APP_SECRET = 'myappsecret'`\n\n\t*It's recommended you use environment variables instead of defining confidential credentials in your settings file*\n\n5. Define `HOST` in `settings.py`\n\n\t`HOST = 'https://3efed1b4.ngrok.com'`\n\n\t**Don't include a trailing backslash**\n\n\t**GOOD:** `https://3efed1b4.ngrok.com` \n\t**BAD:** `https://3efed1b4.ngrok.com/`\n\n6. Add 'django_twitter_auth' to your `INSTALLED_APPS` in `settings.py`.\n\n7. Add the following line to the top of your root `urls.py`\n\n\t`url(r'^twitter/', include('django_twitter_auth.urls', namespace='django_twitter_auth')),`\n\n8. Run migrate to install the `TwitterProfile` model that comes with Simple Django Twitter Auth\n\n\t`python manage.py migrate`\n\n9. That's it! You can now use the `{% url 'django_twitter_auth:login' %}` template tag to kick off the login flow.\n\n## Login Flow\n\n1. Simple Django Twitter Auth provides the following URL `/twitter/login/`. First, you point users here.\n\t- you can also utilize the `{% url 'django_twitter_auth:login' %}` template tag\n\n2. Users are redirected to Twitter where they authorize your application, granting it access to their Twitter profile.\n\n3. After authorizing your app, Twitter redirects users back to your site. Simple Django Twitter Auth then does one of the following:\n\t- Creates a new `TwitterProfile` and `User`\n\t- Finds an existing `TwitterProfile` and `User`\n\t- Finds an existing `TwitterProfile` and `User`, and updates the `TwitterProfile`'s OAuth2 tokens. *(if a Twitter user revoked access to your app, and then re-authorizes it later, Simple Django Twitter Auth simply updates the access tokens.)*\n\n4. Simple Django Twitter Auth manually logs in the user, and redirects them back to the page they started the flow from.\n\n## Components\n\n#### TwitterProfile\n\nSimple Django Twitter Auth provides a `TwitterProfile` model. This model has the following attributes:\n\n**TwitterProfile.OAUTH_TOKEN**\n\nOAuth2 token provided by Twitter during authorization. Can be used to consume/publish additional data on behalf of Twitter User.\n\n**TwitterProfile.OAUTH_TOKEN_SECRET**\n\nOAuth2 token secret provided by Twitter during authorization. Can be used to consume/publish additional data on behalf of Twitter User.\n\n**TwitterProfile.username**\n\nUser's Twitter username. '@' not included.\n\n**TwitterProfile.user**\n\nWhenever a new `TwitterProfile` is created, a `User` is also created and a OneToOne relationship is established with the `TwitterProfile`.\n\nThe `username` attribute of the `User` is set to the same value as `TwitterProfile.username`.\n\nSimple Django Twitter Auth uses `django.contrib.auth.get_user_model()` to get the current `User` model.\n\nReverse lookup is available through `user.twitterprofile`.\n\n## Customization\n\n#### TWITTER_NEW_USER_URL\n\nDefine a location for new users to be redirected to. Eg:\n\n\t`TWITTER_NEW_USER_URL = \"/welcome/\"`\n\nUsers are logged in by the time they arrive here.\n\nIf this setting is defined, Simple Django Twitter Auth will append a `redir_to` URL parameter when forwarding. This will contain the URL the user started the login flow from. For example, `?redir_to=/welcome/`.\n\nYou can catch this parameter to redirect the user back to where they started after you're done any custom logic defined in your `TWITTER_NEW_USER_URL` view.\n\n#### TWITTER_AUTH_RANDOM_PASSWORD \n\nDefault is `True`.\n\nWhen Simple Django Twitter Auth creates a `User` and ties it to the `TwitterProfile`, a random base64 encoded 128-bit password using `os.urandom()` is created for the `User`. This is just a protective measure, so that the `User` isn't created with a blank password.\n\nYou can turn this off if you want, by setting `TWITTER_AUTH_RANDOM_PASSWORD` to `False`.\n\n## Running Tests\n\nCan manually run tests by calling `manage.py test django_twitter_auth` \n\n## Coming Soon \n\n- Signals to provide additional customization\n- Pictures in the readme\n- Better example\n- More coming soon...", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dylanbfox/simple-django-twitter-auth", "keywords": null, "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "simple-django-twitter-auth", "package_url": "https://pypi.org/project/simple-django-twitter-auth/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/simple-django-twitter-auth/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/dylanbfox/simple-django-twitter-auth" }, "release_url": "https://pypi.org/project/simple-django-twitter-auth/1.0/", "requires_dist": null, "requires_python": null, "summary": "Simple Django app to allow users to login with Twitter", "version": "1.0" }, "last_serial": 1482376, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "3aa6be66652b3712b05e808452e63920", "sha256": "708ff1e892b40205a40d9573ca111457a4d614558818d643a09252d41feb6cec" }, "downloads": -1, "filename": "simple-django-twitter-auth-1.0.zip", "has_sig": false, "md5_digest": "3aa6be66652b3712b05e808452e63920", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18322, "upload_time": "2015-03-29T17:01:07", "url": "https://files.pythonhosted.org/packages/9a/47/ecd97366be67c499cc55aef876afc1791bb8fabcdd0d9e99ad7f03be3180/simple-django-twitter-auth-1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3aa6be66652b3712b05e808452e63920", "sha256": "708ff1e892b40205a40d9573ca111457a4d614558818d643a09252d41feb6cec" }, "downloads": -1, "filename": "simple-django-twitter-auth-1.0.zip", "has_sig": false, "md5_digest": "3aa6be66652b3712b05e808452e63920", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18322, "upload_time": "2015-03-29T17:01:07", "url": "https://files.pythonhosted.org/packages/9a/47/ecd97366be67c499cc55aef876afc1791bb8fabcdd0d9e99ad7f03be3180/simple-django-twitter-auth-1.0.zip" } ] }