Python 在Django应用程序中集成LinkedIn API

Python 在Django应用程序中集成LinkedIn API,python,django,linkedin,Python,Django,Linkedin,我正试图使用在中给出的python Linkedin包,使用以下代码从Linkedin API获取访问令牌 def get_linkedin_token(request): access_code = request.GET.get('code') if access_code is None: request.session['authentication'] = linkedin.LinkedInAuthentication( LI

我正试图使用在中给出的python Linkedin包,使用以下代码从Linkedin API获取访问令牌

def get_linkedin_token(request):

    access_code = request.GET.get('code')

    if access_code is None:
    request.session['authentication'] = linkedin.LinkedInAuthentication(
                LINKEDIN_CONSUMER_KEY,
                LINKEDIN_CONSUMER_SECRET,
                RETURN_URL,
                linkedin.PERMISSIONS.enums.values())
    **url = request.session['authentication'].authorization_url**
        return HttpResponseRedirect(url)

    else:
        request.session['authentication'].authorization_code = access_code
        access_token = authentication.get_access_token()
        return HttpResponse(access_token)
上面的代码给了我一个类型错误,地址是url“不可JSON序列化”;当我在浏览器中打开url时,它工作正常,但在应用程序中描述了它的给出错误。 出什么事了?我怎么能修好它?
提前感谢

以上代码是正确的,需要在线路上进行细微的修改

access_token = authentication.get_access_token()
应该是

access_token = request.session['authentication'].get_access_token()

因为我将身份验证对象初始化为会话变量,并且在调用时没有使用request.session[]。因此,在这样做之后,任何人都可以使用python LinkedIn轻松获得LinkedIn API的访问令牌;我调用了authentication.get\u access\u token()而不是request.session[authentication].get\u access\u token()在else案例的第二行中,这样您就找到了解决方案。如果你认为它对其他人有用,那么请写一个正式的答案(解释为什么你的解决方案是这个解决方案)。如果没有,则删除您的问题。