summaryrefslogtreecommitdiff
path: root/coip
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-11-07 18:46:56 +0100
committerLeif Johansson <leifj@sunet.se>2011-11-07 18:46:56 +0100
commitaf973256dbcfbcbd4007cbfb1b571143a2ceee55 (patch)
tree69e13e75369b19a50c30ded8407bdd1f94fd124a /coip
parent72efcafbd4dc984a87b2dad0ce4a6d0df8b339ae (diff)
a simple oauth2-protected hello-world
Diffstat (limited to 'coip')
-rw-r--r--coip/apps/name/views.py7
-rw-r--r--coip/urls.py3
2 files changed, 8 insertions, 2 deletions
diff --git a/coip/apps/name/views.py b/coip/apps/name/views.py
index b50526c..e77a6ed 100644
--- a/coip/apps/name/views.py
+++ b/coip/apps/name/views.py
@@ -16,6 +16,7 @@ from coip.apps.name.forms import NameEditForm, NewNameForm, NameDeleteForm,\
from django.shortcuts import get_object_or_404
from django.contrib.auth.models import User
from django.db.models import Q
+from django_oauth2_lite.decorators import oauth2_required
@login_required
def delete(request,id):
@@ -235,4 +236,8 @@ def search(request):
if request.REQUEST.has_key('term'):
term = request.REQUEST['term']
list = [{'label': name.shortname(),'value': name.id} for name in Name.objects.filter(Q(short__contains=term) | Q(value__contains=term))]
- return json_response(list) \ No newline at end of file
+ return json_response(list)
+
+@oauth2_required(scope='memberships')
+def hello(request):
+ return json_response('world') \ No newline at end of file
diff --git a/coip/urls.py b/coip/urls.py
index c1470e0..49df4d4 100644
--- a/coip/urls.py
+++ b/coip/urls.py
@@ -74,5 +74,6 @@ urlpatterns = patterns('',
(r'^api/', include(v1_api.urls)),
(r'^opensocial/1.0/rpc', 'coip.apps.opensocial.common.system'),
(r'^opensocial/', include(opensocial_v1.urls)),
- (r'^oauth2/', include('django_oauth2_lite.urls'))
+ (r'^hello/?', 'coip.apps.name.views.hello'),
+ (r'^oauth2/', include('django_oauth2_lite.urls'))
)