{"id":16588369,"url":"https://github.com/oliverjash/oauth-authorization-header","last_synced_at":"2025-10-29T08:33:45.710Z","repository":{"id":143902361,"uuid":"91687769","full_name":"OliverJAsh/oauth-authorization-header","owner":"OliverJAsh","description":"Generates OAuth Authorization header.","archived":false,"fork":false,"pushed_at":"2017-11-12T20:55:05.000Z","size":14,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T00:23:50.812Z","etag":null,"topics":["authorization","javascript","oauth","request","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OliverJAsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T11:56:37.000Z","updated_at":"2021-05-14T01:28:43.000Z","dependencies_parsed_at":"2023-04-29T19:25:04.279Z","dependency_job_id":null,"html_url":"https://github.com/OliverJAsh/oauth-authorization-header","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Foauth-authorization-header","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Foauth-authorization-header/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Foauth-authorization-header/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OliverJAsh%2Foauth-authorization-header/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OliverJAsh","download_url":"https://codeload.github.com/OliverJAsh/oauth-authorization-header/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238795448,"owners_count":19531744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","javascript","oauth","request","typescript"],"created_at":"2024-10-11T22:56:33.704Z","updated_at":"2025-10-29T08:33:40.383Z","avatar_url":"https://github.com/OliverJAsh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oauth-authorization-header\n\nGenerates OAuth `Authorization` header.\n\nUnder the hood, this module generates the string using the [battle-tested code](https://github.com/request/request/blob/b12a6245d9acdb1e13c6486d427801e123fdafae/lib/oauth.js#L130) hidden inside the popular [request] library. The request library is concerned about making requests, and thus does not document its standalone OAuth API, nor does it make it very easy to use—hence the existence of this module.\n\nThe library is written in TypeScript and is published in JavaScript with type declaration files.\n\n## Installation\n\n```\nyarn add oauth-authorization-header\n```\n\n## Example\n\nTwitter:\n\n``` ts\nimport fetch from 'node-fetch';\nimport * as querystring from 'querystring';\nimport { getOAuthAuthorizationHeader, OAuthOptions } from '../src';\n\nconst CONSUMER_KEY = 'YOUR_CONSUMER_KEY';\nconst CONSUMER_SECRET = 'YOUR_CONSUMER_SECRET';\nconst CALLBACK = 'YOUR_CALLBACK';\n\nconst hostUrl = 'https://api.twitter.com';\n\nconst fetchFromTwitter = ({\n    oAuth,\n    baseUrlPath,\n    method,\n    queryParams,\n}: {\n    oAuth: OAuthOptions,\n    baseUrlPath: string,\n    method: 'GET' | 'POST' | 'DELETE' | 'PATCH' | 'UPDATE',\n    queryParams: {},\n}) =\u003e {\n    const baseUrl = `${hostUrl}${baseUrlPath}`;\n    const paramsStr = Object.keys(queryParams).length \u003e 0\n        ? `?${querystring.stringify(queryParams)}`\n        : '';\n    const url = `${baseUrl}${paramsStr}`;\n\n    const authorizationHeader = getOAuthAuthorizationHeader({\n        oAuth,\n        url,\n        method,\n        queryParams,\n        formParams: {},\n    });\n\n    const headers = { 'Authorization': authorizationHeader };\n    return fetch(url, {\n        method,\n        headers,\n    });\n};\n\nconst getRequestToken = () =\u003e (\n    fetchFromTwitter({\n        oAuth: {\n            consumerKey: CONSUMER_KEY,\n            consumerSecret: CONSUMER_SECRET,\n            callback: CALLBACK,\n        },\n        baseUrlPath: `/oauth/request_token`,\n        method: 'POST',\n        queryParams: {},\n    })\n);\n\ngetRequestToken().then(response =\u003e {\n    // …\n});\n```\n\n## Development\n\n```\nyarn\nyarn compile\nyarn lint\n```\n\n[request]: https://github.com/request/request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverjash%2Foauth-authorization-header","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foliverjash%2Foauth-authorization-header","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foliverjash%2Foauth-authorization-header/lists"}