OAuthClient
import { OAuthClient } from "https://raw.githubusercontent.com/snsinfu/deno-oauth-1.0a/main/mod.ts";
OAuth 1.0a client.
A client object does not send actual request to a server. Its task is to compute OAuth parameters (or an Authorization header) for you.
class OAuthClient { }
constructor(opts: ClientOptions);
§Constructors
§
new OAuthClient(opts: ClientOptions)
[src]Constructor sets common parameters for signing requests.
const client = new OAuthClient({
consumer: { key: "GDTEA1vY", secret: "cE1DdqeY6K35LwDM" },
signature: HMAC_SHA1,
});
@param opts.consumer
- Consumer token (sometimes called app token).
@param opts.signature
- Signature method to use.
§Properties
§
signature: SignatureMethod
[src]§Methods
§
Signs a request.
const params = client.sign("GET", "https://api.example.com/profile", {
token: { key: "spMmUxWb", secret: "SbovVfkxHTwcmupb" },
});
console.log(params.oauth_signature);
@param method
- HTTP method.
@param url
- URL to request. This may contain query parameters.
@param opts.token
- Request token (token for an authorized user).
@param opts.params
- Overriden OAuth parameters. You can set special protocol parameters like oauth_callback or specify oauth_timestamp and oauth_nonce for testing.
@param opts.body
- Request body to sign. If you will send a form-encoded body, you MUST pass it as a URLSearchParams object; it's signed along with other OAuth parameters as mandated by the standard. Otherwise, you MAY pass a stringified body. Then, the string is hashed and an oauth_body_hash parameter (which is an extension) is added to the signed parameters. Omit this option if you do not want a body hash.
@return
Signed OAuth protocol parameters as a SignedOAuthParams object. The result can be converted to an Authorization header (toAuthHeader), query parameters or form-encoded body (toQueryParams).