﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35188	Redirect URI Mismatch with Box API	Arnautt	nobody	"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
}}}"	Bug	closed	contrib.auth	5.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
