OAuth握手复制错误 [英] OAuth Handshake Copy Error

查看:146
本文介绍了OAuth握手复制错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用复制的API REST创建PoC,但我有一个问题,当我尝试获取访问令牌:

I am trying to build a PoC with the API REST of Copy but I have a problem when I try to get the ACCESS TOKEN:

消息:oauth_problem = signature_invalid& debug_sbs = GET& https%3A%2F%2Fapi.copy.com% ...

Message: oauth_problem=signature_invalid&debug_sbs=GET&https%3A%2F%2Fapi.copy.com%...

@app.route('/get_access_token')
def get_access_token():
    print "Get Access Token"
    oauth_verifier = request.args['oauth_verifier']
    oauth_token = request.args['oauth_token']
    print oauth_token + " & " + oauth_verifier

    # Create your consumer with the proper key/secret.
    consumer = oauth.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
    print "Consumer: ", consumer
    client = oauth.Client(consumer)
    url = access_url + "?oauth_verifier=%s&oauth_token=%s" % (oauth_verifier, oauth_token)
    print url
    resp, content = client.request(url, "GET")
    print "Resp: ", resp
    print "Content: ", content

    return content



<

I would appreciate any help.

推荐答案

我已经能够解决我自己的问题。问题是创建一个新的消费者(我有一个为oauth握手的第一步),而不是使用由库提供​​的oauth.Token(我把oauth_verifier和oauth_token解决方法)

I have been able to solve my own issue. The problem was the creation of a new consumer (I had one for the first step of the oauth handshake) and not using the oauth.Token provided by the library (I put the oauth_verifier and the oauth_token with a workaround)

解决方案:

@app.route('/get_access_token')
def get_access_token():
    print "Get Access Token"
    try:
        oauth_verifier = request.args['oauth_verifier']
        oauth_token = request.args['oauth_token']
        print oauth_token + " & " + oauth_verifier

        token = oauth.Token(oauth_token, request_token_secret) # request_token_secret is global
        token.set_verifier(oauth_verifier)
        client = oauth.Client(consumer, token) #consumer is global

        url = "https://api.copy.com/oauth/access"
        resp, content = client.request(url, "GET")
        print "Resp: ", resp
        print "Content: ", content
        return content

    except Exception as e:
        return e.message()

这篇关于OAuth握手复制错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆