title: FastAPI - HTTP Basic Auth - Choose own usernam/pass & Base64
body: <p><strong>How can I add my username and password and add a base64 for Basic Auth. (<a href="https://fastapi.tiangolo.com/tutorial/security/http-basic-auth/" rel="nofollow noreferrer">https://fastapi.tiangolo.com/tutorial/security/http-basic-auth/</a>)</strong></p>
  
  <p>I have read quite bit and I ended up even to setup <em>OAuth2 with Password (and hashing), Bearer with JWT tokens</em> but that ended up to be too much for me and all I need is only a simple Basic Auth and to add a small protection on it, basically add a base64.</p>
  
  <p>The idea was to have something like this in header:</p>
  
  <p><code>{'Authorization': 'Basic aGVsbG86d29ybGQ='} #hello:world</code></p>
  
  <p>However my knowledge is pretty low and I am having the first issue with even configure on how to use my own username and password with:</p>
  
  <pre><code>from fastapi import Depends, FastAPI
  from fastapi.security import HTTPBasic, HTTPBasicCredentials
  
  app = FastAPI()
  
  security = HTTPBasic()
  
  
  @app.get("/users/me")
  def read_current_user(credentials: HTTPBasicCredentials = Depends(security)):
      return {"username": credentials.username, "password": credentials.password}
  </code></pre>
  
  <p><img src="https://user-images.githubusercontent.com/15836342/71070207-93588480-217a-11ea-9dfb-40ed6b1a8d02.png" alt="The Sign IN"></p>
  
  <h3>My question:</h3>
  
  <p>How can I choose my own username and password and after that be ablet o use base64 to encode/decode the Authorization to be able to send to header something like:</p>
  
  <p><code>{'Authorization': 'Basic aGVsbG86d29ybGQ='} #hello:world</code></p>