Re: [Django] #35188: Redirect URI Mismatch with Box API

2024-02-13 Thread Django
#35188: Redirect URI Mismatch with Box API
--+--
 Reporter:  Arnautt   |Owner:  nobody
 Type:  Bug   |   Status:  closed
Component:  contrib.auth  |  Version:  5.0
 Severity:  Normal|   Resolution:  invalid
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by David Sanders):

 * status:  new => closed
 * resolution:   => invalid

Comment:

 Trac is not a support request channel. If you need help setting up Django
 you can get help from a friendly community member in one of the official
 support channels: https://www.djangoproject.com/community/ ☺️
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018da1c555a1-7da53b40-a0bf-4fd6-aa0c-203a4aab745b-00%40eu-central-1.amazonses.com.


[Django] #35188: Redirect URI Mismatch with Box API

2024-02-13 Thread Django
#35188: Redirect URI Mismatch with Box API
+
   Reporter:  Arnautt   |  Owner:  nobody
   Type:  Bug   | Status:  new
  Component:  contrib.auth  |Version:  5.0
   Severity:  Normal|   Keywords:
   Triage Stage:  Unreviewed|  Has patch:  0
Needs documentation:  0 |Needs tests:  0
Patch needs improvement:  0 |  Easy pickings:  0
  UI/UX:  0 |
+
 When attempting to authenticate with the Box API, user encounter a
 "redirect_uri_mismatch" error. Here are the steps to reproduce :


 - Set up a Box application and configure the redirect URI to
 http://localhost:8000/

 - Create the minimal example to reproduce the error

 1. **settings.py**


 {{{
 BOX_CLIENT_ID = 'YOUR_BOX_CLIENT_ID'
 BOX_CLIENT_SECRET = 'YOUR_BOX_CLIENT_SECRET'
 }}}


 2. **views.py**


 {{{
 from django.shortcuts import redirect
 from django.conf import settings
 from boxsdk import OAuth2

 def authenticate_with_box(request):
 oauth = OAuth2(
 client_id=settings.BOX_CLIENT_ID,
 client_secret=settings.BOX_CLIENT_SECRET,
 )
 auth_url, csrf_token =
 
oauth.get_authorization_url(redirect_url=request.build_absolute_uri(reverse('upload')))
 request.session['csrf_token'] = csrf_token
 return redirect(auth_url)

 def upload(request):
 return render(request, "upload.html", {'access_token':
 request.session["access_token"]})

 }}}


 3. **urls.py**


 {{{
 from django.urls import path
 from .views import authenticate_with_box

 urlpatterns = [
 path('', authenticate_with_box, name='authenticate_with_box'),
 path('upload/', views.upload, name='upload'),
 ]
 }}}


 - Run the server


 {{{
 python manage.py runserver
 }}}
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018da1bdd1f9-bccaada7-e600-4d87-af8e-a756dad802f6-00%40eu-central-1.amazonses.com.