GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.joinmastodon.org — Obtaining client app access - Mastodon documentation Obtaining client app accessGetting accustomed to the basics of authentication and authorization. Authentication and authorizationUp until this point, we’ve been working with publicly available information, but not all information is public. Some information requires permission before viewing it, in order to audit who is requesting that information (and to potentially revoke or deny access). This is where OAuth comes in. OAuth is a mechanism for generating access tokens that can be used to authenticate (verify) that a request is coming from a specific client, and ensure that the requested action is authorized (allowed) by the server’s access control policies. Creating our applicationThe first thing we will need to do is to register an application, in order to be able to generate access tokens later. The application can be created like so: In the above example, we specify the client name and website, which will be shown on statuses if applicable. But more importantly, note the following two parameters:
You can also create applications by POSTing a JSON body to the same endpoint, as documented in POST /api/v1/apps. As of Mastodon 4.3.0, you can discover which scopes the server supports along with other information by making a request to the /.well-known/oauth-authorization-server endpoint.We should see a CredentialApplication entity returned, but for now, we only care about The Treat the client_id and client_secret properties as if they are passwords. We recommend you encrypt these when storing in your cache, to prevent accidental credential exposure.Example authentication code flowNow that we have an application, let’s obtain an access token that will authenticate our requests as that client application. To do so, use POST /oauth/token like so: Note the following:
The response of this method is a Token entity. We will need the Treat the access_token as if it were a password. We recommend you encrypt this value when storing in your cache, to prevent accidental credential exposure.To use it in requests, add the HTTP header Let’s verify that our obtained credentials are working by calling GET /api/v1/apps/verify_credentials: If we’ve obtained our token and formatted our request correctly, we should see our details returned to us as an Application entity (without the What we can do with authenticationWith our authenticated client application, we can view relations of an account with GET /api/v1/accounts/:id/following and GET /api/v1/accounts/:id/followers. Also, some instances may require authentication for methods that would otherwise be public, so if you encountered any authentication errors while playing around with public methods, then those methods should now work. Last updated |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |