[英]How can I get an oauth access token in sharepoint 2013?
I have this site here: http://msdn.microsoft.com/en-us/library/jj164022(v=office.15).aspx 我在这里有这个网站: http : //msdn.microsoft.com/en-us/library/jj164022(v = office.15).aspx
the text in some part says: The following JavaScript code demonstrates how to make this GET request that returns a JSON representation of all of a site's lists by using JQuery. 某些部分的文本说:以下JavaScript代码演示了如何使用JQuery生成此GET请求,该请求返回所有站点列表的JSON表示。 It also assumes that you have a valid OAuth access token that is stored in the accessToken variable.
它还假定您具有存储在accessToken变量中的有效OAuth访问令牌。 You do not need the access token if you make this call from inside an app web, as you would in a SharePoint-hosted app.
如果您从应用程序Web中进行此调用,则不需要访问令牌,就像在SharePoint托管的应用程序中一样。
jQuery.ajax({
url: http:// site url/_api/web/lists,
type: "GET",
headers: {
"ACCEPT","application/json;odata=verbose",
"Authorization", "Bearer " + accessToken
},
})
the specific question is how can I get the access token?? 具体问题是如何获取访问令牌?
There doesn't seem to be a way to get the access token only using JavaScript. 似乎没有办法仅使用JavaScript获取访问令牌。 You need to use an app to generate the access token.
您需要使用应用程序生成访问令牌。 See the Sharepoint OAuth Tips and FAQs for more information about how to get the token.
有关如何获取令牌的详细信息,请参阅Sharepoint OAuth提示和常见问题解答 。
Your entire approach is incorrect. 你的整个方法都不正确。 When it comes to accessing the REST services of a sharepoint 2013 server using javascript you don't need an Access Token.
在使用javascript访问sharepoint 2013服务器的REST服务时,您不需要访问令牌。 You have to use the Sharepoint 2013 cross-domain library instead.
您必须使用Sharepoint 2013跨域库。
The page at http://msdn.microsoft.com/en-us/library/jj164022.aspx explains after showing a classic REST request using an oauth token: 在使用oauth令牌显示经典REST请求后,请参阅http://msdn.microsoft.com/en-us/library/jj164022.aspx上的页面:
This request would look a little different if you are writing your app in JavaScript but using the SharePoint 2013 cross-domain library.
如果您使用JavaScript编写应用程序但使用SharePoint 2013跨域库,则此请求看起来会略有不同。 In this case, you don't need to provide an access token.
在这种情况下,您不需要提供访问令牌。 The following code demonstrates how this request would look if you are using the cross-domain library and want to receive the OData representation of the lists as XML instead of JSON.
以下代码演示了如果您使用跨域库并希望将列表的OData表示形式接收为XML而不是JSON,此请求将如何显示。 See How to: Access SharePoint 2013 data from remote apps using the cross-domain library for more information about using the cross-domain library.
有关使用跨域库的详细信息,请参阅如何:使用跨域库从远程应用程序访问SharePoint 2013数据。
This is currently the url to that article http://msdn.microsoft.com/en-us/library/fp179927.aspx 这是该文章的网址http://msdn.microsoft.com/en-us/library/fp179927.aspx
This should be your correct answer 这应该是你的正确答案
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.