From 6dca01f9bfc2d45329e67de9c42856ab01fe0860 Mon Sep 17 00:00:00 2001 From: Eugen Date: Wed, 16 Mar 2016 18:39:21 +0100 Subject: [PATCH] Initial Home page --- Testing-with-cURL.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Testing-with-cURL.md diff --git a/Testing-with-cURL.md b/Testing-with-cURL.md new file mode 100644 index 0000000..e052ed6 --- /dev/null +++ b/Testing-with-cURL.md @@ -0,0 +1,11 @@ +Mastodon builds around the idea of being a server first, rather than a client itself. Similarly to how a XMPP chat server communicates with others and with its own clients, Mastodon takes care of federation to other networks, like other Mastodon or GNU Social instances. So Mastodon provides a REST API, and a 3rd-party app system for using it via OAuth2. + +Once logged in on Mastodon, you can go to Authorized Apps -> Register new app here. You can create a new OAuth application, and once you do so, you will get a Client ID and a Client Secret. You can use those with an OAuth client library of your choice, but in this example we want to just use the API over cURL. + +From these two, you will need to acquire an access token. It is possible to do using your account's e-mail and password like this: + + curl -X POST -d "client_id=CLIENT_ID_HEREclient_secret=CLIENT_SECRET_HERE&grant_type=password&username=YOUR_EMAIL&password=YOUR_PASSWORD" -Ss https://mastodon.social/oauth/token + +The response will be a JSON object containing the key `access_token`. Use that token in any API requests by setting a header like this: + + curl --header "Authorization: Bearer ACCESS_TOKEN_HERE" -sS https://mastodon.social/api/statuses/home \ No newline at end of file