SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 I have read and registered App with , after this I have assigned rights with

also i have created oAuth url

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).

share|improve this question
up vote 2 down vote accepted

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:

and also high trust

share|improve this answer

you can get the access token by making a POST request to<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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.