OAuth 握手复制错误

OAuth Handshake Copy Error

我正在尝试使用 Copy 的 API REST 构建 PoC,但是当我尝试获取访问令牌时遇到问题:

消息: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

如有任何帮助,我将不胜感激。

我已经能够解决我自己的问题。问题是创建了一个新的消费者(我在 oauth 握手的第一步有一个)并且没有使用库提供的 oauth.Token (我把 oauth_verifier 和 oauth_token 有解决方法)

解决方法:

@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()