News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
OAuth with Django: 'bytes' object has no attribute 'get'
Tags: oauth2, authentication
Jan 13, 2021 at 9:34am   •   2 replies  •  0 likes
Andrew Schwartz

I'm working through the Authorization Flow Quick Start App using Python Django. This required making a few changes to the Flask code provided, but most of the flow is working. The index page sends me to RingCentral login, which then sends me back to the test page as it should. But when I click on any of the three links on that page I get the same error:

AttributeError at /test/

'bytes' object has no attribute 'get'


Here's the slightly modified code that handles the test page:


def test(request):

platform = SyncConfig.rcsdk.platform()

platform.auth().set_data(request.session['sessionAccessToken'])

if platform.logged_in() == False:

return index(request)

api = request.GET.get('api')

if api == "extension":

resp = platform.get("/restapi/v1.0/account/~/extension")

return resp.response()._content

elif api == "extension-call-log":

resp = platform.get("/restapi/v1.0/account/~/extension/~/call-log")

return resp.response()._content

elif api == "account-call-log":

resp = platform.get("/restapi/v1.0/account/~/call-log")

return resp.response()._content

else:

return render(request, 'sync/test.html')


Has anyone setup a Django authorization flow and can show me where this is breaking?

2 Answers
answered on Jan 13, 2021 at 2:35pm  

I finally figured it out. Just returning resp.response()._content from a view was causing Django problems. I wrote a simple HTML template to display the contents of resp.response()._content, and returned a rendered template with the data included in the context.


 1
answered on Jan 13, 2021 at 11:16am  

Looks like it crashed at this line in Django

api = request.GET.get('api')

Can you try this

api = request.GET['api']



 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us