A while ago a colleague asked me how to test a REST API when you need a token to use the API. He just wanted to verify some data and didn't want to write any code.
You'll need to do some configuration, but once it's setup the REST calls become painless.
Link O365 with a WAAD
Make sure your O365 is linked via a WAAD (Windows Azure Active Directory).
To link a WAAD to your azure account you need to login via the old azure portal http://manage.windowsazure.com and create a new Active directory.
Use an existing directory
Once you click next, you'll be asked to logout from azure and you can login on your O365 account to link both.
Grant a client to obtain a token
Now we have linked our O365 with a WAAD, we need to allow an application to obtain a token from O365.
In the next step you can define the name of your application. I also chose that I'll use a native client as I'm developing a mobile application.
Finally you need to define the redirect url. This url is not a working url but needs to correspond with the configuration of your mobile app.
Now you need to open the configure screen to get the configuration you need to get a token
Be aware that below you can change the permissions you app can get to connect to O365.
Obtain a token
To obtain a token you'll need to install the azure powershell tools. You can install it via your Visual Studio Extensions, but... as we don't want to code you can also download it from: https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/
After installing, make sure you restart your powershell. Check your powershell execution policy by typing in powershell (without the dollar sign):
If it is restricted open a powershell as admin and type (without the dollar sign):
$ Set-ExecutionPolicy RemoteSigned
Next you can use the powershell script from https://gist.github.com/jtourlamain/f456e4f1d402bc713d85 to obtain a token. In the file you'll need to change the following parameters (which can be found in your Azure AD Application configuration:
- redirect URI
When executing the file in powershell, you'll be asked to login. If all goes well, you'll get a new jwt.txt file containing your token. If you need to obtain a new token, first clear your IE cache/data (cleaning the cache from the Edge browser won't help)
Use the token
Now you got an token, open up an REST client. I use Paw2 on mac, but the free postman plugin for the chrome browser will do as well.
My tenant is devprotocol. I can use it to obtain a list of photos by doing a GET to my custom list:
Accept : application/json;odata=verbose
Authorization : Bearer yourLongLongTokenFromAzure
Hope this helps some of you the burden to write a program just to test out an O365 API.