GitHub API returning message requires authentication while I try to login

Viewed 301
const fetchUser =  async () =>{
    let username : any = (document.getElementById('username') as HTMLInputElement).value;
    let password : any = (document.getElementById('password') as HTMLInputElement).value; 
    const profile = await fetch("https://api.github.com/user", {
        headers:{
            'Authorization': 'Basic ' + window.btoa(username + ":" + password)
        }
    })
   const profileResponse = await profile.json()
    console.log(profileResponse)
}
const handleSubmit =(e:any) =>{
    e.preventDefault()
    fetchUser()
}

I tried to log in with GitHub credentials using GitHub API but it returns the required authentication

1 Answers

Github.com has discontinued password authentication to the API using username and password.

Reference

Related