Question

here is the idea: i want to make php web site which will be hosted on my server and it will work with my sharepoint 2013 site hosted on office365.

my sharepoint 2013 site is smeasy.sharepoint.com I have read msdn.microsoft.com/en-us/library/jj687469.aspx and registered App with smeasy.sharepoint.com/_layouts/15/appregnew.aspx , after this I have assigned rights with smeasy.sharepoint.com/_layouts/15/appinv.aspx

also i have created oAuth url

https://smeasy-my.sharepoint.com/_layouts/15/OAuthAuthorize.aspx?client_id=71b572ee-cfc9-49b0-a324-a8cc8ff77f5f&scope=Site.Manage&response_type=code&redirect_uri=https%3A%2F%2Fdev-v.smestorage.com%2F%3Fp%3Doauthlogin%26action%3Dcomplete%26pr_id%3D50%26type%3Dempty2%26spoint2013%3Dy

and got code in response.

The question is: how to get token by code in php (what url to pass this code and how), i just can not find the way how to do this maybe you may help me and point to article? or at least let me know if this possible because right now i am not sure that this is possible on remote server (not azure).

Was it helpful?

Solution

The simple answer is you can't (Or it isn't designed so you can) get the token from your php you need to generate it from the app.

Take a look at the tips and tricks page for more information:

http://msdn.microsoft.com/en-us/library/fp179932%28v=office.15%29#Tokens

and also high trust

http://msdn.microsoft.com/en-us/library/fp179932%28v=office.15%29#S2S

OTHER TIPS

you can get the access token by making a POST request to

https://accounts.accesscontrol.windows.net/<site_realm>/tokens/OAuth/2

with required post parameters in the body. this will return the access token and refresh token which you can use to make REST calls to sharepoint online site and to regenerate the access token once it expires.

refer this post for the complete flow:

SharePoint Online (O365) OAuth Authentication

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top