cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
lorewap3
Community Participant

Has anyone implemented oauth authentication using Django (python)?

Our school is using the django framework and has a lot of tools we've previously built into it for other things. We have a lot of ideas for creating tools to integrate with our canvas instance, but are hitting a wall at getting oauth integration working. As many python scripts as we've found that gather/update data within canvas, I figured we'd be able to find a django app someone made that does the same. But so far I have not. Is anyone out there using the django framework to gather/update data within canvas? 

Even if you're using a token instead of oauth I'd like to hear about it. I'm hoping to not have to write it from scratch or at least get insight from others who have done it before.

Thank you!

5 Replies
RobDitto
Community Champion

lorewap3, assuming you mean the OAuth2 flow for interactive applications, take a look at Harvard University's related Django application:

lorewap3
Community Participant

Thanks Rob! Yes that is pretty much exactly what I was looking for! This will help out immensely.

If I may I'd like to ask one more question out of curiosity. I know the API are pretty straightforward post/get requests that return json objects, which isn't too difficult to program in itself. But I'm curious if anyone has made a django wrapper for making some of these API calls. I know there are a few python ones, I'm wondering if anyone's gone a step further and made an actual django app out of them. 

I know it would be tedious and somewhat pointless to make a wrapper for each API call, but it'd be nice if someone made or at least started to make a wrapper django app for them that I could use as a guide and make additions to the more API calls we make. 

I made a very basic javascript class that does the same thing that we're slowing adding API calls that we use frequently throughout various scripts. Long-term I'd like to do the same with a django app to have a centralized place for all these calls. 

Thanks again!

RobDitto
Community Champion

I'm not really a coder, but I wonder whether an approach of importing the Requests module into your app would help. Here's an example I saw involving a different product's API:

ag3811
Community Participant

At Columbia we have also implemented OAuth connections to Canvas, with Flask and Requests-OAuthlib.  Our code is not currently publicly available, but I would be happy to answer questions.

Requests-OAuthlib: OAuth for Humans — Requests-OAuthlib 0.8.0 documentation 

lawd
Community Participant

I've never done any work with Django (we use Laravel for our framework), but I have built some python scripts to interact with the Canvas api. I just use the standard python Requests library to handle all my python api calls. I am not a Django developer, but I would assume you could require the Requests library into your Django app fairly easily. Let me know if you have any questions about using Requests.