Patreon and Django-AllAuth Integration

401 views
Skip to first unread message

Andrew Stringfield

unread,
Oct 26, 2020, 3:48:01 PM10/26/20
to Django users
Hello all,

    I am trying to use Patreon's API Version 2 with Django 3.1.  I read: https://docs.patreon.com/#third-party-libraries and found that Patreon supported the django-allauth library.  I installed the library by following the instructions of: https://django-allauth.readthedocs.io/en/latest/installation.html.  I start up the default dev server and I go to http://127.0.0.1:8000/accounts/signup/ and fill out the form and hit submit.  I get the response of:
---------------------
Page not found (404)Request Method:
GETRequest URL:
http://127.0.0.1:8000/accounts/profile/

Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:

  1. admin/
  2. accounts/ signup/ [name='account_signup']
  3. accounts/ login/ [name='account_login']
  4. accounts/ logout/ [name='account_logout']
  5. accounts/ password/change/ [name='account_change_password']
  6. accounts/ password/set/ [name='account_set_password']
  7. accounts/ inactive/ [name='account_inactive']
  8. accounts/ email/ [name='account_email']
  9. accounts/ confirm-email/ [name='account_email_verification_sent']
  10. accounts/ ^confirm-email/(?P<key>[-:\w]+)/$ [name='account_confirm_email']
  11. accounts/ password/reset/ [name='account_reset_password']
  12. accounts/ password/reset/done/ [name='account_reset_password_done']
  13. accounts/ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
  14. accounts/ password/reset/key/done/ [name='account_reset_password_from_key_done']
  15. accounts/ social/
  16. accounts/ patreon/

The current path, accounts/profile/, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

---------------------

I want to get data from Patreon, but it looks like I am just creating local user accounts in the database.  What am I doing wrong?

Andréas Kühne

unread,
Oct 26, 2020, 4:33:16 PM10/26/20
to django...@googlegroups.com
Hi,

Django-allauth is used for handling login from SSO third party libraries - EXACTLY what you are getting a response from.

Do you want to use Patreon as a login account provider or do you want to do something else?

Regards,

Andréas


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/090d5b8f-d8cf-4ba7-86b1-35017dec2397n%40googlegroups.com.

Andrew Stringfield

unread,
Oct 26, 2020, 4:45:36 PM10/26/20
to Django users
First, thank you for the response!  I want to use Patreon as a login account provider for my Patrons.  I have been playing around with the code some more.  This is what I have so far:

I created a view with the contents of:
def patreon(request):
        request_string = 'http://patreon.com/oauth2/authorize'
        request_string = request_string + '?response_type=code'
        request_string = request_string + '&client_id=KEY_VARIABLE'
        request_string = request_string + '&redirect_uri=http://website_name.com'
        print(request_string)
        response = requests.get(request_string)
        print(response)
-----------------
The print(response) produces: <Response [403]>.  I looked up this error code and found: "403 Forbidden -- The requested is hidden for administrators only." at the URL of: https://docs.patreon.com/?python#errors
Please also note that the website_name.com is not currently online at this time.  If, I need to make it online, I can.

Ryan Nowakowski

unread,
Oct 27, 2020, 9:28:38 AM10/27/20
to Django users
On Mon, Oct 26, 2020 at 12:16:03PM -0700, Andrew Stringfield wrote:
> Hello all,
>
> I am trying to use Patreon's API Version 2 with Django 3.1. I
> read: https://docs.patreon.com/#third-party-libraries and found that
> Patreon supported the django-allauth library. I installed the library by
> following the instructions
> of: https://django-allauth.readthedocs.io/en/latest/installation.html. I
> start up the default dev server and I go
> to http://127.0.0.1:8000/accounts/signup/ and fill out the form and hit
> submit. I get the response of:
> ---------------------
> Page not found (404)Request Method:
> GETRequest URL:
> http://127.0.0.1:8000/accounts/profile/
>
> Using the URLconf defined in mysite.urls, Django tried these URL patterns,
> in this order:
>
> 1. admin/
> 2. accounts/ signup/ [name='account_signup']
> 3. accounts/ login/ [name='account_login']
> 4. accounts/ logout/ [name='account_logout']
> 5. accounts/ password/change/ [name='account_change_password']
> 6. accounts/ password/set/ [name='account_set_password']
> 7. accounts/ inactive/ [name='account_inactive']
> 8. accounts/ email/ [name='account_email']
> 9. accounts/ confirm-email/ [name='account_email_verification_sent']
> 10. accounts/ ^confirm-email/(?P<key>[-:\w]+)/$
> [name='account_confirm_email']
> 11. accounts/ password/reset/ [name='account_reset_password']
> 12. accounts/ password/reset/done/ [name='account_reset_password_done']
> 13. accounts/ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$
> [name='account_reset_password_from_key']
> 14. accounts/ password/reset/key/done/
> [name='account_reset_password_from_key_done']
> 15. accounts/ social/
> 16. accounts/ patreon/
>
> The current path, accounts/profile/, didn't match any of these.

That's the default LOGIN_REDIRECT_URL[1]. Explicitly set that in your
settings.py to wherever you want the user to land after login succeeds.

[1] https://docs.djangoproject.com/en/3.1/ref/settings/#login-redirect-url

Andrew Stringfield

unread,
Oct 28, 2020, 7:53:42 AM10/28/20
to Django users
Sorry for the late reply.  I found a youtube video of: https://www.youtube.com/watch?v=-TUEM2NCuVE and I followed the instructions as best as I could.  I created a button for a Patreon login and I get the below results:

and in my HTML Body I get: {"error":"invalid_request","error_description":"Mismatching redirect URI.","state":"z5ycBAl8AI5V"}

Andrew Stringfield

unread,
Oct 28, 2020, 7:55:48 AM10/28/20
to Django users
I almost forgot.  I have checked my settings in Django and Patreon and the URL redirect matches for all that I can see.  I have an idea to try and use the testing framework to see what values I am passing to Patreon.

Ryan Nowakowski

unread,
Oct 28, 2020, 9:55:15 AM10/28/20
to django...@googlegroups.com
The patreon error you're seeing might be a different redirect URL than the login redirect URL. i.e. these may be two different problems.

Andrew Stringfield

unread,
Oct 28, 2020, 1:29:57 PM10/28/20
to Django users
I would not be shocked.

Ryan Nowakowski

unread,
Oct 28, 2020, 7:18:05 PM10/28/20
to Django users
Typically oauth requires a callback URL[1] configured at the
provider(Patreon in this case). Maybe double check that? Perhaps that's
what Patreon is referring to("redirect URL") in the error below?

[1] https://django-allauth.readthedocs.io/en/latest/providers.html#providers
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/914b5ef0-c1f0-408b-b1c3-0b1977ddd43an%40googlegroups.com.

Ryan Nowakowski

unread,
Oct 28, 2020, 7:37:51 PM10/28/20
to Django users
Here's the django-allauth callback URL for Patreon:
https://django-allauth.readthedocs.io/en/latest/providers.html#patreon

That "callback URL" needs to be configured in the Patreon dev
portal. Make sure you change the URL to match your Django project's
domain/port/etc.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20201028231642.GR12495%40fattuba.com.

Kayode Oladipo

unread,
Oct 28, 2020, 11:30:56 PM10/28/20
to django...@googlegroups.com
Hello Sir,
You need to set the LOGIN_REDIRECT_URL in your settings.py file.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Andrew Stringfield

unread,
Oct 30, 2020, 8:01:54 AM10/30/20
to Django users
You guys are awesome!  I will try these solutions later this evening.
Reply all
Reply to author
Forward
0 new messages