[英]How to get Salesforce username using REST api?
I am using web server flow for oAuth and simple-salesforce REST api to login the user using the access token and instance url. 我正在为oAuth和simple-salesforce REST api使用Web服务器流,以使用访问令牌和实例URL登录用户。 I have gone through the http://www.salesforce.com/us/developer/docs/api_rest/index.htm documentation and coudn't find anything on it. 我已经浏览了http://www.salesforce.com/us/developer/docs/api_rest/index.htm文档,但找不到任何内容。
Based on your comment saying you're using https://github.com/neworganizing/salesforce-oauth2 : you can do something like : 根据您的评论说您正在使用https://github.com/neworganizing/salesforce-oauth2 :您可以执行以下操作:
import urllib
# After you get the code
response = salesforce_oauth_2.get_token(code)
print urllib.urlopen(response['id'])
The json object response returned by get_token
should contain an id
attribute which is an url that you can query for more information about the current user. get_token
返回的json对象响应应包含一个id
属性,该属性是一个url,您可以查询有关当前用户的更多信息。 See here for more details (paragraph 5). 有关更多详细信息,请参见此处 (第5段)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.