{"id":20307340,"url":"https://github.com/oktadev/okta-node-rest-api-example","last_synced_at":"2025-08-24T14:19:31.948Z","repository":{"id":40294327,"uuid":"145129269","full_name":"oktadev/okta-node-rest-api-example","owner":"oktadev","description":"Simple REST API with Node and OAuth 2.0","archived":false,"fork":false,"pushed_at":"2023-03-13T22:40:48.000Z","size":245,"stargazers_count":16,"open_issues_count":9,"forks_count":7,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-07-23T00:24:40.054Z","etag":null,"topics":["javascript","nodejs","oauth2","rest","rest-api"],"latest_commit_sha":null,"homepage":"https://developer.okta.com/blog/2018/08/21/build-secure-rest-api-with-node","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oktadev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2018-08-17T14:16:23.000Z","updated_at":"2025-02-19T22:32:07.000Z","dependencies_parsed_at":"2025-04-11T15:11:46.681Z","dependency_job_id":"ae7fa0dc-3e99-4c72-a1d6-cb85ad94418f","html_url":"https://github.com/oktadev/okta-node-rest-api-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oktadev/okta-node-rest-api-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-rest-api-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-rest-api-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-rest-api-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-rest-api-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oktadev","download_url":"https://codeload.github.com/oktadev/okta-node-rest-api-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oktadev%2Fokta-node-rest-api-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271885407,"owners_count":24838666,"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","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","nodejs","oauth2","rest","rest-api"],"created_at":"2024-11-14T17:17:18.023Z","updated_at":"2025-08-24T14:19:31.927Z","avatar_url":"https://github.com/oktadev.png","language":"JavaScript","readme":"# Simple REST API with Node and OAuth 2.0\n\nThis example app shows how to create a REST API in Node and secure it with OAuth 2.0 Client Credentials using Okta. This also has an example client written as a CLI that can authenticate with Okta and use the REST API.\n\n## Getting Started\n\n### Install Dependencies\n\nAfter cloning the repository, simply run `npm install` to install the dependencies.\n\n### Save Environment Variables\n\nIf you don't have one already, [sign up for a free Okta Developer account](https://www.okta.com/developer/signup/). Log in to your developer console to get the following information.\n\nCreate a file named `.env` that has the following variables, all obtained from your Okta developer console:\n\n* **ISSUER**\n\n  Log in to your developer console and navigate to **API** \u003e **Authorization Servers**. Copy the `Issuer URI` for the `default` server.\n\n* **SCOPE**\n\n  Click on the word `default` to get details about the authorization server. Go to the **Scopes** tab and click the **Add Scope** button. Give it a name and optionally a description. The example app is for a parts manager, so for example you could name it `parts_manager`.\n\n* **CLIENT_ID**\n\n  Navigate to **Applications**, then click the **Add Application** button. Select **Service**, then click **Next**. Choose a name then click **Done**. The **Client ID** is shown on the next page.\n\n* **CLIENT_SECRET**\n\n  The **Client Secret** is on the same page as the **Client ID**\n\nWhen you're done, your `.env` file should look something like this:\n\n```bash\nISSUER=https://dev-123456.oktapreview.com/oauth2/default\nSCOPE=parts_manager\nCLIENT_ID=0123456789abcdefghij\nCLIENT_SECRET=0123456789abcdefghijklmnopqrstuvwxyz0123\n```\n\n### Run the Server\n\nTo run the server, run `npm start` from the terminal.\n\n### Run the Client\n\nTo make secure API requests, you'll need to use the client located at `client.js`.\n\n**USAGE**\n\n\u003e **node client** url \\[method\\] \\[jsonString\\]\n\n* **url** *(required)*: the path to your server along with the endpoint (e.g. `http://localhost:3000/parts`)\n* **method** *(optional)*: the HTTP verb for the REST call (e.g. `delete` or `post`). Defaults to `get`\n* **jsonString** *(optional)*: stringified JSON data for use in `put` or `post` calls (e.g. `'{\"partNumber\":\"asdf-1234\"}'`)\n\n**EXAMPLES**\n\n* `node client http://localhost:3000/parts`: get a list of all parts\n* `node client http://localhost:3000/parts post '{\"partNumber\":\"asdf-1234\"}'`: creates a new part with part number `asdf-1234`\n* `node client http://localhost:3000/parts/1`: gets details about the part with and `id` of `1`\n* `node client http://localhost:3000/parts/7 put '{\"name\":\"A single dairy farm\"}'`: updates the `name` field of the part with an `id` of `7`\n* `node client http://localhost:3000/parts/11 delete`: deletes the part with an `id` of `11`\n\n## License\n\nApache 2.0, see [LICENSE](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fokta-node-rest-api-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foktadev%2Fokta-node-rest-api-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foktadev%2Fokta-node-rest-api-example/lists"}