{"componentChunkName":"component---node-modules-rocketseat-gatsby-theme-docs-core-src-templates-docs-query-js","path":"/quick-start/authentication/","result":{"data":{"mdx":{"id":"48f9a8ac-a7f7-51a2-a971-61e46f0075c5","excerpt":"Overview In this quick tutorial, we'll cover everything you need to authenticate your calls with our API. Find your API key Your API key is easily located…","fields":{"slug":"/quick-start/authentication/"},"frontmatter":{"title":"Authentication","description":null,"image":null,"disableTableOfContents":null},"body":"function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\n/* @jsx mdx */\nvar _frontmatter = {\n  \"title\": \"Authentication\"\n};\n\nvar makeShortcode = function makeShortcode(name) {\n  return function MDXDefaultShortcode(props) {\n    console.warn(\"Component \" + name + \" was not imported, exported, or provided by MDXProvider as global scope\");\n    return mdx(\"div\", props);\n  };\n};\n\nvar layoutProps = {\n  _frontmatter: _frontmatter\n};\nvar MDXLayout = \"wrapper\";\nreturn function MDXContent(_ref) {\n  var components = _ref.components,\n      props = _objectWithoutProperties(_ref, [\"components\"]);\n\n  return mdx(MDXLayout, _extends({}, layoutProps, props, {\n    components: components,\n    mdxType: \"MDXLayout\"\n  }), mdx(\"h2\", {\n    \"id\": \"overview\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h2\"\n  }, {\n    \"href\": \"#overview\",\n    \"aria-label\": \"overview permalink\",\n    \"className\": \"anchor before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Overview\"), mdx(\"p\", null, \"In this quick tutorial, we'll cover everything you need to authenticate your calls with our API.\"), mdx(\"hr\", null), mdx(\"h2\", {\n    \"id\": \"find-your-api-key\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h2\"\n  }, {\n    \"href\": \"#find-your-api-key\",\n    \"aria-label\": \"find your api key permalink\",\n    \"className\": \"anchor before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Find your API key\"), mdx(\"p\", null, mdx(\"span\", _extends({\n    parentName: \"p\"\n  }, {\n    \"className\": \"gatsby-resp-image-wrapper\",\n    \"style\": {\n      \"position\": \"relative\",\n      \"display\": \"block\",\n      \"marginLeft\": \"auto\",\n      \"marginRight\": \"auto\",\n      \"maxWidth\": \"700px\"\n    }\n  }), \"\\n      \", mdx(\"span\", _extends({\n    parentName: \"span\"\n  }, {\n    \"className\": \"gatsby-resp-image-background-image\",\n    \"style\": {\n      \"paddingBottom\": \"59.583333333333336%\",\n      \"position\": \"relative\",\n      \"bottom\": \"0\",\n      \"left\": \"0\",\n      \"backgroundImage\": \"url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAMABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAECBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAdylQhh//8QAFBABAAAAAAAAAAAAAAAAAAAAIP/aAAgBAQABBQJf/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAFBABAAAAAAAAAAAAAAAAAAAAIP/aAAgBAQAGPwJf/8QAGRAAAwEBAQAAAAAAAAAAAAAAAAERYRBB/9oACAEBAAE/IUnXCaTT1i5//9oADAMBAAIAAwAAABAoz//EABURAQEAAAAAAAAAAAAAAAAAAAAR/9oACAEDAQE/EFf/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAdEAEAAgEFAQAAAAAAAAAAAAABABExIUFRYYHR/9oACAEBAAE/ECDWr3uW5HsKZU6D7AJjQxEGf//Z')\",\n      \"backgroundSize\": \"cover\",\n      \"display\": \"block\"\n    }\n  })), \"\\n  \", mdx(\"picture\", {\n    parentName: \"span\"\n  }, \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/82c6ebb55d61057fd461f7d18b023f78/8ac56/api-key-location.webp 240w\", \"/static/82c6ebb55d61057fd461f7d18b023f78/d3be9/api-key-location.webp 480w\", \"/static/82c6ebb55d61057fd461f7d18b023f78/426ac/api-key-location.webp 700w\"],\n    \"sizes\": \"(max-width: 700px) 100vw, 700px\",\n    \"type\": \"image/webp\"\n  })), \"\\n        \", mdx(\"source\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"srcSet\": [\"/static/82c6ebb55d61057fd461f7d18b023f78/09b79/api-key-location.jpg 240w\", \"/static/82c6ebb55d61057fd461f7d18b023f78/7cc5e/api-key-location.jpg 480w\", \"/static/82c6ebb55d61057fd461f7d18b023f78/29d31/api-key-location.jpg 700w\"],\n    \"sizes\": \"(max-width: 700px) 100vw, 700px\",\n    \"type\": \"image/jpeg\"\n  })), \"\\n        \", mdx(\"img\", _extends({\n    parentName: \"picture\"\n  }, {\n    \"className\": \"gatsby-resp-image-image\",\n    \"src\": \"/static/82c6ebb55d61057fd461f7d18b023f78/29d31/api-key-location.jpg\",\n    \"alt\": \"API Key Location\",\n    \"title\": \"API Key Location\",\n    \"loading\": \"lazy\",\n    \"style\": {\n      \"width\": \"100%\",\n      \"height\": \"100%\",\n      \"margin\": \"0\",\n      \"verticalAlign\": \"middle\",\n      \"position\": \"absolute\",\n      \"top\": \"0\",\n      \"left\": \"0\"\n    }\n  })), \"\\n      \"), \"\\n    \")), mdx(\"p\", null, \"Your API key is easily located within your account at API.Bible:\"), mdx(\"ol\", null, mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"First, \", mdx(\"a\", _extends({\n    parentName: \"li\"\n  }, {\n    \"href\": \"%5Bhttps://www.example.com%5D(https://api.bible/sign-in)\"\n  }), \"log in here\"), \".\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"After logging in, you are redirected to your dashboard. If you are unsure, you can always click \", mdx(\"em\", {\n    parentName: \"li\"\n  }, \"\\\"API Product\\\"\"), \" in the navigation, then \", mdx(\"em\", {\n    parentName: \"li\"\n  }, \"\\\"Dashboard\\\"\"), \" in the dropdown.\"), mdx(\"li\", {\n    parentName: \"ol\"\n  }, \"Your key will be in the top right corner of your dashboard.\")), mdx(\"p\", null, mdx(\"strong\", {\n    parentName: \"p\"\n  }, \"Note:\"), \" Because your API key is unique to your account, do not share this key anywhere and secure it appropriately in your codebase.\"), mdx(\"hr\", null), mdx(\"h2\", {\n    \"id\": \"test-your-api-key\",\n    \"style\": {\n      \"position\": \"relative\"\n    }\n  }, mdx(\"a\", _extends({\n    parentName: \"h2\"\n  }, {\n    \"href\": \"#test-your-api-key\",\n    \"aria-label\": \"test your api key permalink\",\n    \"className\": \"anchor before\"\n  }), mdx(\"svg\", _extends({\n    parentName: \"a\"\n  }, {\n    \"aria-hidden\": \"true\",\n    \"focusable\": \"false\",\n    \"height\": \"16\",\n    \"version\": \"1.1\",\n    \"viewBox\": \"0 0 16 16\",\n    \"width\": \"16\"\n  }), mdx(\"path\", _extends({\n    parentName: \"svg\"\n  }, {\n    \"fillRule\": \"evenodd\",\n    \"d\": \"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"\n  })))), \"Test your API key\"), mdx(\"p\", null, \"Now that you have your key, let's test it out in a real API call. Since authenticating your calls works the same across all requests, you can reference this for future requests should you run into any issues with authentication.\"), mdx(\"p\", null, \"Here's a cURL request that fetches all Bibles your account has access to:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-sh\"\n  }), \"curl --request GET \\\\\\n--url https://rest.api.bible/v1/bibles \\\\\\n--header 'api-key: YOUR_API_KEY'\\n\")), mdx(\"p\", null, \"Essentially, our authentication uses a variation of HTTP Basic Auth. In each request you make, you'll want to place your API key in the header of the request, like this:\\n\", mdx(\"inlineCode\", {\n    parentName: \"p\"\n  }, \"---header 'api-key: YOUR_API_KEY'\")), mdx(\"p\", null, \"Here's how this request might look in vanilla Javascript:\"), mdx(\"pre\", null, mdx(\"code\", _extends({\n    parentName: \"pre\"\n  }, {\n    \"className\": \"language-js\"\n  }), \"const res = await fetch(\\\"https://rest.api.bible/v1/bibles\\\", {\\n  headers: { \\\"api-key\\\": \\\"YOUR_API_KEY\\\" },\\n});\\nconst data = await res.json();\\nconsole.log(data);\\n\")), mdx(\"hr\", null), mdx(\"p\", null, \"And that's it! You should now be set to authenticate every request you make with our API. Up next, we'll discuss a few common questions developers have when starting out with API.Bible.\"));\n}\n;\nMDXContent.isMDXComponent = true;","headings":[{"depth":2,"value":"Overview"},{"depth":2,"value":"Find your API key"},{"depth":2,"value":"Test your API key"}]}},"pageContext":{"slug":"/quick-start/authentication/","prev":{"label":"Create Your Account","link":"/quick-start/create-your-account"},"next":{"label":"Working with Bibles","link":"/quick-start/working-with-bibles"},"githubEditUrl":"https:/github.com/americanbible/api-bible-docs/tree/master/src/@rocketset/gatsby-theme-docs/src/docs/quick-start/authentication.mdx"}}}