I’m attempting to have soundcloud authorize my django app, which i have successfully registered with soundcloud. I pass in the details supplied during registration as well as the callback uri (http://localhost:8000/profile/).
I call the login page, which prompts me to allow my app to access my soundcloud account. I accept.
def login(request):
if request.method == 'GET':
client = soundcloud.Client(
client_id=settings.CLIENT_ID,
client_secret=settings.CLIENT_SECRET,
redirect_uri=settings.REDIRECT_URI,
)
return HttpResponseRedirect(client.authorize_url())
return render(request, 'login.html', {})
Soundcloud provides my callback link with the authorization_code appended.
http://localhost:8000/profile/?code=xxxxxxxxxxxxxxxx...etc...&signed_up=0
To extract the code in order to get the exchange token, I do this:
urlpatterns = patterns('core.views',
url(r'^login/$', 'login', name='login'),
(r'^profile/\?code=(?P<code>[\d\w]{32}).*/$', 'profile'),
url(r'^admin/', include(admin.site.urls)),
)
but get a ‘page not found’. What am I doing wrong here?? I have checked the regex in shell and it returns the code…
I’m new to oAuth and api’s so any help is appreciated.
Make your URL Pattern look like this:
In your profile view, you can get
codefrom query string like this:Easy and Simple !!