【问题标题】:Howt to authenticate linkedin rest api?如何验证linkedin rest api?
【发布时间】:2017-04-20 00:55:36
【问题描述】:

我正在尝试使用linkedin rest api 制作一个网络应用程序。 我正在遵循these 的指示。我已经完成了第 1 步。 我在Linkedin 上创建了一个应用程序。我获得了该应用的 Client IDClient Secret

我被第 2 步卡住了。如何为我的应用获取 USER_TOKENUSER_SECRET?任何帮助,将不胜感激。

【问题讨论】:

  • 您使用哪种语言?
  • @pratibha 我也被困在第 2 步,我使用 javascript 作为客户端

标签: oauth-2.0 linkedin-api


【解决方案1】:

尝试遵循这个。对于 Python 链接库。

consumer = oauth.Consumer(consumer_key,consumer_secret)
client = oauth.Client(consumer)

request_token_url = 'https://api.linkedin.com/uas/oauth/requestToken'
resp, content = client.request(request_token_url, "POST")
if resp['status'] != '200':
    raise Exception("Invalid response %s." % resp['status'])

print content

request_token = dict(urlparse.parse_qsl(content))

print "Requesr Token:",  "\n"
print "- oauth_token        = %s" % request_token['oauth_token'], "\n"
print "- oauth_token_secret = %s" % request_token['oauth_token_secret'], "\n"

authorize_url = 'https://api.linkedin.com/uas/oauth/authorize'
print "Go to the following link in your browser:", "\n"
print "%s?oauth_token=%s" % (authorize_url, request_token['oauth_token']), "\n"

accepted = 'n'
while accepted.lower() == 'n':
    accepted = raw_input('Have you authorized me? (y/n) ')
oauth_verifier = raw_input('What is the PIN? ')

access_token_url = 'https://api.linkedin.com/uas/oauth/accessToken'
token = oauth.Token(request_token['oauth_token'],        request_token['oauth_token_secret'])
token.set_verifier(oauth_verifier)
client = oauth.Client(consumer, token)

resp, content = client.request(access_token_url, "POST")
access_token = dict(urlparse.parse_qsl(content))

print "Access Token:", "\n"
print "- oauth_token        = %s" % access_token['oauth_token'], "\n"
print "- oauth_token_secret = %s" % access_token['oauth_token_secret']
print "You may now access protected resources using the access tokens above."

【讨论】:

  • 您好,我收到消息异常:无效响应 400。=> 你能帮忙吗?
猜你喜欢
  • 2021-10-16
  • 1970-01-01
  • 1970-01-01
  • 2016-05-24
  • 2014-05-04
  • 2014-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多