Auth systems/OAuth/Design

<!DOCTYPE html>  Auth systems/OAuth/Design 

 Features  To simplify the design, and to work with many of the existing OAuth client libraries that current work with Twitter's OAuth 1.0 implementation, we will start by implementing OAuth 1.0a <li data-parsoid='{"dsr":[204,279,2,0]}'> We can move to one or more OAuth 2 flows in next year if there is demand</li> <li data-parsoid='{"dsr":[280,434,2,0]}'> This will allow users to use HTTPS or HTTP when using OAuth, since every call must be signed. To keep things simple, we may only support HMAC to start?</li></ul></li></ul>

<ul data-parsoid='{"dsr":[436,632,0,0]}'><li data-parsoid='{"dsr":[436,632,1,0]}'> There will be an Application Registration page, for registering applications <ul data-parsoid='{"dsr":[515,632,0,0]}'><li data-parsoid='{"dsr":[515,632,2,0]}'> If this process is usable for power users, it may enable Desktop apps, as each user would generate their own appid</li></ul></li></ul>

<ul data-parsoid='{"dsr":[634,1469,0,0]}'><li data-parsoid='{"dsr":[634,1469,1,0]}'> There will be an approval page, where a logged in user will grant permissions to an application <ul data-parsoid='{"dsr":[732,1469,0,0]}'><li data-parsoid='{"dsr":[732,781,2,0]}'> Users should be warned of privacy implications</li> <li data-parsoid='{"dsr":[782,821,2,0]}'> Should users reenter their password?</li> <li data-parsoid='{"dsr":[822,1469,2,0]}'> Allow application to update their privileges? This is not part of the specification, but should be a simple addition. <ul data-parsoid='{"dsr":[943,1469,0,0]}'><li data-parsoid='{"dsr":[943,1469,3,0]}'> What's the difference between an application that already has X updating to add Y, and the application just making a new request for X+Y? <ul data-parsoid='{"dsr":[1085,1469,0,0]}'><li data-parsoid='{"dsr":[1085,1469,4,0]}'> The application would need to start using new client credentials (we don't want to track what users have accepted or not), so when the user is redirected to the WMF to authorize the new client, in the UI, it's the difference between saying that an app wants to authorize with certain permissions vs. saying an existing application would like to to add / remove these permissions.</li></ul></li></ul></li></ul></li></ul>

<ul data-parsoid='{"dsr":[1471,1587,0,0]}'><li data-parsoid='{"dsr":[1471,1587,1,0]}'> There will be a page where Users can see and manage their approved applications <ul data-parsoid='{"dsr":[1553,1587,0,0]}'><li data-parsoid='{"dsr":[1553,1566,2,0]}'> See grants</li> <li data-parsoid='{"dsr":[1567,1587,2,0]}'> revoke if desired</li></ul></li></ul>

<ul data-parsoid='{"dsr":[1589,1695,0,0]}'><li data-parsoid='{"dsr":[1589,1695,1,0]}'> The MW API accepts signed requests <ul data-parsoid='{"dsr":[1626,1695,0,0]}'><li data-parsoid='{"dsr":[1626,1654,2,0]}'> wgUser setup for the user</li> <li data-parsoid='{"dsr":[1655,1695,2,0]}'> Hook ApiCheckCanExecute to authorize?</li></ul></li></ul>

<h3 data-parsoid='{"dsr":[1697,1722,3,3]}'> Permission grants

<p data-parsoid='{"dsr":[1724,2009,0,0]}'>Users will have the ability to grant relatively fine-grained permissions for which API features a client is allowed to use. The list of granted permissions will be supplied by the AuthPlugin (i.e. OAuth), but will otherwise not depend on the specific implementation of the auth plugin.

<ul data-parsoid='{"dsr":[2011,3980,0,0]}'><li data-parsoid='{"dsr":[2011,2251,1,0]}'> Granted permissions are identified by string tokens. These are entirely independent of the existing user rights system: to successfully execute a module, both the existing user rights checks and the granted permissions check have to pass.</li> <li data-parsoid='{"dsr":[2252,2483,1,0]}'> Granted permissions are checked by the API code calling a method on $wgAuth, which then (if necessary) loads the list of granted permissions and calls a method on the API module to check if the granted permissions are sufficient.</li> <li data-parsoid='{"dsr":[2484,2628,1,0]}'> By default, there will be one perimssion token per API module (per action, or per query prop / list / meta), named the same as the API module.</li> <li data-parsoid='{"dsr":[2629,3112,1,0]}'> API modules can override this. For example, <ul data-parsoid='{"dsr":[2675,3112,0,0]}'><li data-parsoid='{"dsr":[2675,2752,2,0]}'> ApiBlock and ApiUnblock would probably both use the same permission token.</li> <li data-parsoid='{"dsr":[2753,2821,2,0]}'> Many query submodules would probably use a generic "query" token.</li> <li data-parsoid='{"dsr":[2822,3112,2,0]}'> On the other hand, ApiEditPage would probably have separate tokens for basic editing, creating new pages, editing the user's css/js, editing protected pages, editing MediaWiki-namespace pages, etc. Which one(s) it checks for any particular query would be depend on the page being edited.</li></ul></li> <li data-parsoid='{"dsr":[3113,3715,1,0]}'> An API module may use the list of granted rights (passed from $wgAuth before -&gt;execute, as mentioned above) to modify its behavior when executed. For example, it might prevent using any deleted revision data (as if the user lacked the 'deletedtext' user right) unless a "viewdeleted" permission were granted, but otherwise proceed normally. <ul data-parsoid='{"dsr":[3458,3715,0,0]}'><li data-parsoid='{"dsr":[3458,3715,2,0]}'> One idea to implement this would be for the API module to be able to instruct the User object to temporarily filter out certain user rights, so for all intents and purposes the user <i data-parsoid='{"dsr":[3643,3660,2,2]}'>wouldn't have</i> "deletedtext" during the execution of that API module.</li></ul></li> <li data-parsoid='{"dsr":[3716,3980,1,0]}'> API modules will also have to be able to supply a list of which permissions they might need to be granted; this may be output as part of the online help, and will be used to create a (cached) list of all possible granted rights for use by OAuth (if it needs it).</li></ul>

<p data-parsoid='{"dsr":[3982,3997,0,0]}'>Open questions: <ul data-parsoid='{"dsr":[3998,4270,0,0]}'><li data-parsoid='{"dsr":[3998,4270,1,0]}'> Should i18n of granted permissions be forced to use systematic message keys, e.g. "granted-permission-{$name}-name", "granted-permission-{$name}-description"? Or should it be allowed that the API module specifies the key? And if the latter, how are conflicts dealt with?</li></ul>

<h3 data-parsoid='{"dsr":[4272,4287,3,3]}'> Logging <ul data-parsoid='{"dsr":[4288,5104,0,0]}'><li data-parsoid='{"dsr":[4288,4469,1,0]}'> Lots of people gave the input that it would be desirable to log the appid, userid, and revisionid (or other identifying id for the action), to identify apps that were misbehaving.</li> <li data-parsoid='{"dsr":[4470,4621,1,0]}'> Logs would only be written on edits, or api calls that made a change to the system (specifically, we will exclude any calls for searching or reading)</li> <li data-parsoid='{"dsr":[4622,4699,1,0]}'> Viewing these logs would be available to a privileged user, and/or the user</li> <li data-parsoid='{"dsr":[4700,5104,1,0]}'> Collection/Storage: It seems like we could use either the EventLogging system, or our own logging table, to collect and store the data <ul data-parsoid='{"dsr":[4837,5104,0,0]}'><li data-parsoid='{"dsr":[4837,5021,2,0]}'> EL is asynchronous, which is nice. However, this would mean other MW users, who wanted to use OAuth, would either need to have EventLogging setup, or not have a log of the activity.</li> <li data-parsoid='{"dsr":[5022,5104,2,0]}'> For the anticipated load, keeping the logs on extension1 would probably be fine</li></ul></li></ul>

<h3 data-parsoid='{"dsr":[5106,5134,3,3]}'> Implementation Notes <ul data-parsoid='{"dsr":[5135,6369,0,0]}'><li data-parsoid='{"dsr":[5135,6241,1,0]}'> While discussing implementation strategies (irc check-in 20130404) <ul data-parsoid='{"dsr":[5204,6241,0,0]}'><li data-parsoid='{"dsr":[5204,5257,2,0]}'> OAuth should likely be implemented as an extension</li> <li data-parsoid='{"dsr":[5258,5345,2,0]}'> The extension should be usable by mediawiki installs that do not include CentralAuth</li> <li data-parsoid='{"dsr":[5346,5552,2,0]}'> For the WMF deployment, some CentralAuth aspects are necessary. Likely will need hooks to allow CentralAuth to update pieces, or we may extend some classes to implement CentralAuth-specific functionality</li> <li data-parsoid='{"dsr":[5553,5815,2,0]}'> The storage for OAuth data (Client registration, user permissions, logging) will be in a single database. User permissions will include a "wiki" parameter to allow giving a client permissions on only some wikis, or "*" for authorizing the client on all wikis.</li> <li data-parsoid='{"dsr":[5816,6241,2,0]}'> We'll probably use some pieces from existing/reference libraries to handle the OAuth encoding and signatures (one library had a good implementation of both RSA and HMAC signatures in ~50 loc). For actual interactions, we'll probably write the integrations from scratch. We are not trying developing our own library. <ul data-parsoid='{"dsr":[6135,6241,0,0]}'><li data-parsoid='{"dsr":[6135,6241,3,0]}'> NB: we'll chose a couple libraries soon to test as clients, to ensure our system integrates with them.</li></ul></li></ul></li> <li data-parsoid='{"dsr":[6242,6369,1,0]}'> It seems like a good idea to require https for the WMF endpoints, to address <a rel="mw:ExtLink/Numbered" href="http://tools.ietf.org/html/rfc5849#section-4.3" data-parsoid='{"targetOff":6368,"dsr":[6321,6369,null,null]}'>[1]</a></li></ul>

<h3 data-parsoid='{"dsr":[6371,6393,3,3]}'> Open Questions <ul data-parsoid='{"dsr":[6394,6750,0,0]}'><li data-parsoid='{"dsr":[6394,6513,1,0]}'> Does a Consumer need to get an AccessToken for each wiki, or will a single Token for each user authorization suffice?</li> <li data-parsoid='{"dsr":[6514,6750,1,0]}'> Should/Can we enforce using Authorization headers only, as recommended in the standard? Adding the information to the body or query parameters is supported, but the header is preferred <a rel="mw:ExtLink/Numbered" href="http://oauth.net/core/1.0a/#consumer_req_param" data-parsoid='{"targetOff":6748,"dsr":[6701,6749,null,null]}'>[2]</a>.</li></ul>

<h2 data-parsoid='{"dsr":[6752,6782,2,2]}'> Basic Authorization Flow <dl data-parsoid='{"dsr":[6783,6816,0,0]}'><dd data-parsoid='{"dsr":[6783,6816,1,0]}'> Diagram of the basic authn flow</dd></dl>

<p data-parsoid='{"dsr":[6818,6851,0,0]}'><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"600px"}],"cacheKey":"","img":{"h":1311,"w":1843,"wdset":true},"dsr":[6818,6851,null,null]}'><a href="../../File:OAuth-basicSVG.svg" data-parsoid='{"a":{"href":"../../File:OAuth-basicSVG.svg"}}'><img resource="../../File:OAuth-basicSVG.svg" src="http://upload.wikimedia.org/wikipedia/mediawiki/thumb/7/73/OAuth-basicSVG.svg/600px-OAuth-basicSVG.svg.png" height="427" width="600" data-parsoid='{"a":{"resource":"../../File:OAuth-basicSVG.svg"},"sa":{"resource":"File:OAuth-basicSVG.svg"}}'></a>

<h2 data-parsoid='{"dsr":[6853,6886,2,2]}'> Wireframes of pages with UI

<dl data-parsoid='{"dsr":[6888,6934,0,0]}'><dd data-parsoid='{"dsr":[6888,6934,1,0]}'> Page for app-owners to register their client</dd></dl> <p data-parsoid='{"dsr":[6935,6976,0,0]}'><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"600px"}],"cacheKey":"","img":{"h":1205,"w":1205,"wdset":true},"dsr":[6935,6976,null,null]}'><a href="../../File:0_ClientRegistration-1.svg" data-parsoid='{"a":{"href":"../../File:0_ClientRegistration-1.svg"}}'><img resource="../../File:0_ClientRegistration-1.svg" src="http://upload.wikimedia.org/wikipedia/mediawiki/thumb/9/9d/0_ClientRegistration-1.svg/600px-0_ClientRegistration-1.svg.png" height="600" width="600" data-parsoid='{"a":{"resource":"../../File:0_ClientRegistration-1.svg"},"sa":{"resource":"File:0_ClientRegistration-1.svg"}}'></a>

<dl data-parsoid='{"dsr":[6978,7069,0,0]}'><dd data-parsoid='{"dsr":[6978,7069,1,0]}'> Result page after submission. Secret is only generated and shown if no rsa key was given.</dd></dl> <p data-parsoid='{"dsr":[7070,7111,0,0]}'><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"600px"}],"cacheKey":"","img":{"h":1524,"w":1488,"wdset":true},"dsr":[7070,7111,null,null]}'><a href="../../File:0_ClientRegistration-2.svg" data-parsoid='{"a":{"href":"../../File:0_ClientRegistration-2.svg"}}'><img resource="../../File:0_ClientRegistration-2.svg" src="http://upload.wikimedia.org/wikipedia/mediawiki/thumb/8/8e/0_ClientRegistration-2.svg/600px-0_ClientRegistration-2.svg.png" height="615" width="600" data-parsoid='{"a":{"resource":"../../File:0_ClientRegistration-2.svg"},"sa":{"resource":"File:0_ClientRegistration-2.svg"}}'></a>

<dl data-parsoid='{"dsr":[7113,7179,0,0]}'><dd data-parsoid='{"dsr":[7113,7179,1,0]}'> Page user see when they are redirected to the wiki by the Client</dd></dl> <p data-parsoid='{"dsr":[7180,7213,0,0]}'><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"600px"}],"cacheKey":"","img":{"h":1524,"w":1240,"wdset":true},"dsr":[7180,7213,null,null]}'><a href="../../File:4_UserApproval.svg" data-parsoid='{"a":{"href":"../../File:4_UserApproval.svg"}}'><img resource="../../File:4_UserApproval.svg" src="http://upload.wikimedia.org/wikipedia/mediawiki/thumb/e/ef/4_UserApproval.svg/600px-4_UserApproval.svg.png" height="737" width="600" data-parsoid='{"a":{"resource":"../../File:4_UserApproval.svg"},"sa":{"resource":"File:4_UserApproval.svg"}}'></a>

<dl data-parsoid='{"dsr":[7215,7305,0,0]}'><dd data-parsoid='{"dsr":[7215,7305,1,0]}'> Page user sees when they want to manage their authorizations (may in their preferences?)</dd></dl> <p data-parsoid='{"dsr":[7306,7335,0,0]}'><span typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"600px"}],"cacheKey":"","img":{"h":1524,"w":2587,"wdset":true},"dsr":[7306,7335,null,null]}'><a href="../../File:UserManage.svg" data-parsoid='{"a":{"href":"../../File:UserManage.svg"}}'><img resource="../../File:UserManage.svg" src="http://upload.wikimedia.org/wikipedia/mediawiki/thumb/4/4c/UserManage.svg/600px-UserManage.svg.png" height="353" width="600" data-parsoid='{"a":{"resource":"../../File:UserManage.svg"},"sa":{"resource":"File:UserManage.svg"}}'></a>

<h2 data-parsoid='{"dsr":[7337,7366,2,2]}'> Pages / Basic data flow

<h3 data-parsoid='{"dsr":[7368,7407,3,3]}'> Special:OAuthClientRegistration <p data-parsoid='{"dsr":[7408,7554,0,0]}'>Special page where app providers register their "Client". Only over ssl if $wgSecureLogin. Disallow javascript, etc. Probably legal agreement too.

<ul data-parsoid='{"dsr":[7556,7770,0,0]}'><li data-parsoid='{"dsr":[7556,7770,1,0]}'> Inputs: <ul data-parsoid='{"dsr":[7566,7770,0,0]}'><li data-parsoid='{"dsr":[7566,7591,2,0]}'> Client's Name (string)</li> <li data-parsoid='{"dsr":[7592,7624,2,0]}'> Permission (list of strings?)</li> <li data-parsoid='{"dsr":[7625,7632,2,0]}'> Wiki</li> <li data-parsoid='{"dsr":[7633,7661,2,0]}'> Callback URL (url string)</li> <li data-parsoid='{"dsr":[7662,7729,2,0]}'> (optional) Restrict to IP Address (IP Address, or maybe subnet?)</li> <li data-parsoid='{"dsr":[7730,7751,2,0]}'> (optional) RSA Key</li> <li data-parsoid='{"dsr":[7752,7770,2,0]}'> Contact address</li></ul></li></ul>

<ul data-parsoid='{"dsr":[7772,7917,0,0]}'><li data-parsoid='{"dsr":[7772,7917,1,0]}'> Processing: <ul data-parsoid='{"dsr":[7786,7917,0,0]}'><li data-parsoid='{"dsr":[7786,7820,2,0]}'> Ensure name is unique and valid</li> <li data-parsoid='{"dsr":[7821,7859,2,0]}'> Ensure callback isn't blacklisted ?</li> <li data-parsoid='{"dsr":[7860,7884,2,0]}'> Generate Client Token</li> <li data-parsoid='{"dsr":[7885,7917,2,0]}'> Create DB object (unapproved)</li></ul></li></ul>

<ul data-parsoid='{"dsr":[7919,7996,0,0]}'><li data-parsoid='{"dsr":[7919,7996,1,0]}'> Return (page): <ul data-parsoid='{"dsr":[7936,7996,0,0]}'><li data-parsoid='{"dsr":[7936,7951,2,0]}'> Client Token</li> <li data-parsoid='{"dsr":[7952,7996,2,0]}'> Client Secret, if an RSA key wasn't input</li></ul></li></ul>

<h3 data-parsoid='{"dsr":[7998,8045,3,3]}'> Special:OAuthClientRegistrationApproval <p data-parsoid='{"dsr":[8046,8149,0,0]}'>list of applications that need to be approved by authorized person. Probably also a form to Block apps? <dl data-parsoid='{"dsr":[8150,8315,0,0]}'><dd data-parsoid='{"dsr":[8150,8315,1,0]}'> Apps that were submitted by users with confirmed email addresses should be identifiable as well, since that may give us some extra level of trust for approving it.</dd></dl>

<h3 data-parsoid='{"dsr":[8317,8347,3,3]}'> Special:OAuth/initiate <p data-parsoid='{"dsr":[8348,8413,0,0]}'>(This will be called by the Client app, so no human interaction.) <ul data-parsoid='{"dsr":[8414,8691,0,0]}'><li data-parsoid='{"dsr":[8414,8691,1,0]}'> Input: <ul data-parsoid='{"dsr":[8423,8691,0,0]}'><li data-parsoid='{"dsr":[8423,8448,2,0]}'> (optional) OAuth realm</li> <li data-parsoid='{"dsr":[8449,8484,2,0]}'> oauth_consumer_key (rand string)</li> <li data-parsoid='{"dsr":[8485,8538,2,0]}'> oauth_signature_method ["HMAC-SHA1" or "RSA-SHA1"]</li> <li data-parsoid='{"dsr":[8539,8574,2,0]}'> oauth_timestamp (unix timestamp)</li> <li data-parsoid='{"dsr":[8575,8623,2,0]}'> oauth_nonce (random string to prevent replay)</li> <li data-parsoid='{"dsr":[8624,8655,2,0]}'> oauth_callback (encoded url)</li> <li data-parsoid='{"dsr":[8656,8691,2,0]}'> oauth_signature (encoded string)</li></ul></li></ul>

<ul data-parsoid='{"dsr":[8693,8921,0,0]}'><li data-parsoid='{"dsr":[8693,8921,1,0]}'> Processing <ul data-parsoid='{"dsr":[8706,8921,0,0]}'><li data-parsoid='{"dsr":[8706,8766,2,0]}'> Ensure Client is in good standing (approved, not blocked)</li> <li data-parsoid='{"dsr":[8767,8786,2,0]}'> Verify Signature</li> <li data-parsoid='{"dsr":[8787,8805,2,0]}'> Check freshness</li> <li data-parsoid='{"dsr":[8806,8839,2,0]}'> Ensure nonce has not been used</li> <li data-parsoid='{"dsr":[8840,8921,2,0]}'> Check callback is ok (it was the one, or one of the ones, that was registered)</li></ul></li></ul>

<ul data-parsoid='{"dsr":[8923,9036,0,0]}'><li data-parsoid='{"dsr":[8923,9036,1,0]}'> Return: <ul data-parsoid='{"dsr":[8933,9036,0,0]}'><li data-parsoid='{"dsr":[8933,8963,2,0]}'> oauth_token (random string)</li> <li data-parsoid='{"dsr":[8964,9001,2,0]}'> oauth_token_secret (random string)</li> <li data-parsoid='{"dsr":[9002,9036,2,0]}'> oauth_callback_confirmed (true)</li></ul></li></ul>

<h3 data-parsoid='{"dsr":[9038,9069,3,3]}'> Special:OAuth/authorize <p data-parsoid='{"dsr":[9070,9197,0,0]}'>Special page accessed by end users, to approve the Client for their account. Only ssl if $wgSecureLogin. No javascript allowed.

<ul data-parsoid='{"dsr":[9199,9254,0,0]}'><li data-parsoid='{"dsr":[9199,9254,1,0]}'> Input: <ul data-parsoid='{"dsr":[9208,9254,0,0]}'><li data-parsoid='{"dsr":[9208,9249,2,0]}'> oauth_token (from return of /initiate)</li> <li data-parsoid='{"dsr":[9250,9254,2,0]}'> ?</li></ul></li></ul>

<ul data-parsoid='{"dsr":[9256,9428,0,0]}'><li data-parsoid='{"dsr":[9256,9428,1,0]}'> Processing: <ul data-parsoid='{"dsr":[9270,9428,0,0]}'><li data-parsoid='{"dsr":[9270,9293,2,0]}'> Ensure token is good</li> <li data-parsoid='{"dsr":[9294,9321,2,0]}'> Ensure User is logged in</li> <li data-parsoid='{"dsr":[9322,9395,2,0]}'> Retrieve Client info based on token, ensure client is in good standing</li> <li data-parsoid='{"dsr":[9396,9428,2,0]}'> Show page asking for approval</li></ul></li></ul>

<ul data-parsoid='{"dsr":[9430,9533,0,0]}'><li data-parsoid='{"dsr":[9430,9533,1,0]}'> Return (Redirect to callback url with): <ul data-parsoid='{"dsr":[9472,9533,0,0]}'><li data-parsoid='{"dsr":[9472,9499,2,0]}'> oauth_token (from Input)</li> <li data-parsoid='{"dsr":[9500,9533,2,0]}'> oauth_verifier (random string)</li></ul></li></ul>

<p typeof="mw:Placeholder" data-parsoid='{"dsr":[9535,9535,0,0]}'><br data-parsoid='{"dsr":[9535,9535,0,0]}'> <h3 data-parsoid='{"dsr":[9536,9563,3,3]}'> Special:OAuth/token <p data-parsoid='{"dsr":[9564,9615,0,0]}'>(Accessed by Client App only, no human interaction) <ul data-parsoid='{"dsr":[9616,9905,0,0]}'><li data-parsoid='{"dsr":[9616,9905,1,0]}'> Input: <ul data-parsoid='{"dsr":[9625,9905,0,0]}'><li data-parsoid='{"dsr":[9625,9650,2,0]}'> (optional) OAuth realm</li> <li data-parsoid='{"dsr":[9651,9672,2,0]}'> oauth_consumer_key</li> <li data-parsoid='{"dsr":[9673,9687,2,0]}'> oauth_token</li> <li data-parsoid='{"dsr":[9688,9738,2,0]}'> oauth_signature_method ["HMAC-SHA1"|"RSA-SHA1"]</li> <li data-parsoid='{"dsr":[9739,9774,2,0]}'> oauth_timestamp (unix timestamp)</li> <li data-parsoid='{"dsr":[9775,9823,2,0]}'> oauth_nonce (random string to prevent replay)</li> <li data-parsoid='{"dsr":[9824,9869,2,0]}'> oauth_verifier (from return of /authorize)</li> <li data-parsoid='{"dsr":[9870,9905,2,0]}'> oauth_signature (encoded string)</li></ul></li></ul>

<ul data-parsoid='{"dsr":[9907,10054,0,0]}'><li data-parsoid='{"dsr":[9907,10054,1,0]}'> Processing: <ul data-parsoid='{"dsr":[9921,10054,0,0]}'><li data-parsoid='{"dsr":[9921,9981,2,0]}'> Ensure Client is in good standing (approved, not blocked)</li> <li data-parsoid='{"dsr":[9982,10001,2,0]}'> Verify Signature</li> <li data-parsoid='{"dsr":[10002,10020,2,0]}'> Check freshness</li> <li data-parsoid='{"dsr":[10021,10054,2,0]}'> Ensure nonce has not been used</li></ul></li></ul>

<ul data-parsoid='{"dsr":[10056,10142,0,0]}'><li data-parsoid='{"dsr":[10056,10142,1,0]}'> Return: <ul data-parsoid='{"dsr":[10066,10142,0,0]}'><li data-parsoid='{"dsr":[10066,10100,2,0]}'> oauth_token (new random string)</li> <li data-parsoid='{"dsr":[10101,10142,2,0]}'> oauth_token_secret (new random string)</li></ul></li></ul>

<h3 data-parsoid='{"dsr":[10144,10159,3,3]}'> api.php <ul data-parsoid='{"dsr":[10160,10452,0,0]}'><li data-parsoid='{"dsr":[10160,10452,1,0]}'> Input also includes: <ul data-parsoid='{"dsr":[10183,10452,0,0]}'><li data-parsoid='{"dsr":[10183,10208,2,0]}'> (optional) OAuth realm</li> <li data-parsoid='{"dsr":[10209,10230,2,0]}'> oauth_consumer_key</li> <li data-parsoid='{"dsr":[10231,10268,2,0]}'> oauth_token (returned from /token)</li> <li data-parsoid='{"dsr":[10269,10319,2,0]}'> oauth_signature_method ["HMAC-SHA1"|"RSA-SHA1"]</li> <li data-parsoid='{"dsr":[10320,10363,2,0]}'> oauth_timestamp (current unix timestamp)</li> <li data-parsoid='{"dsr":[10364,10416,2,0]}'> oauth_nonce (new random string to prevent replay)</li> <li data-parsoid='{"dsr":[10417,10452,2,0]}'> oauth_signature (encoded string)</li></ul></li></ul>

<dl data-parsoid='{"dsr":[10454,10547,0,0]}'><dd data-parsoid='{"dsr":[10454,10547,1,0]}'> By the spec, these inputs can come in via the Authorization header, or as query parameters.</dd></dl>

<ul data-parsoid='{"dsr":[10549,10770,0,0]}'><li data-parsoid='{"dsr":[10549,10770,1,0]}'> Processing: <ul data-parsoid='{"dsr":[10563,10770,0,0]}'><li data-parsoid='{"dsr":[10563,10623,2,0]}'> Ensure Client is in good standing (approved, not blocked)</li> <li data-parsoid='{"dsr":[10624,10643,2,0]}'> Verify Signature</li> <li data-parsoid='{"dsr":[10644,10662,2,0]}'> Check freshness</li> <li data-parsoid='{"dsr":[10663,10696,2,0]}'> Ensure nonce has not been used</li> <li data-parsoid='{"dsr":[10697,10742,2,0]}'> Ensure token is good (exists, not expired)</li> <li data-parsoid='{"dsr":[10743,10770,2,0]}'> Load User based on token</li></ul></li></ul>