Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
Getting status of 400 - {"error":"invalid_grant"} On Authentication

I created my own website (www.luig.us). I create a basic IDE for SQL server to teach kids SQL, DML only.

It requires the user to enter an username and password at the beginning to get an token to use the service.

On local, everything works fine, but when I put it on my site, hosted by go-daddy, I will get the same message every time and I don't have a clue why.

{"error":"invalid_grant"}

This is my java script code - look for Authorize. Any help is appreciated. I followed this article closely https://www.c-sharpcorner.com/UploadFile/736ca4/token-based-authentication-in-web-api-2/



function Authorize() {
    let bearer = "Basic Q01JUzMwOERTMzA4OndlYkFQSQ=="
    var email = document.getElementById("email").value;
    var password = document.getElementById("password").value;
    var userNameAndPasswordFilled = (email != "" && password != "");
    if (!userNameAndPasswordFilled) {
        $("#formError").show('fast');
    }
    else {
        var bodyOfRequest = {
            grant_type: "password",
            username: email,
            password: password
        };
        $.ajax({
            type: "POST",
            url: uriManager.access,
            beforeSend: function (request) {
                request.setRequestHeader("Authorization", bearer);
            },
            data: bodyOfRequest,
            success: function (response) {
                sessionStorage.setItem(programKeyWords.BearerToken, response.access_token);
                $('#LogonModal').modal('hide');
            },
            error: function (response) {
                $("#formError").show('fast');
            }
        });
    }
}


over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I can't say much without more information but first thing I would check is if you actually have users in your database (or whatever oauth you're using). The error you're getting can likely be caused if you don't actually have a user with that username and password in your oauth database.

The endpoint you're using for uriManager.access is where you have to check if that user actually exists.

over 4 years ago · Santiago Trujillo Report

0

The problem wasn't with the code. The problem was with:

  1. The connection string. It was not correct.
  2. I was encrypting the username and password and it wasn't matching correctly because of special characters

What I did to fix it.

  1. fixed the connection string
  2. fixed the algorithm to store a hash instead of string.
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!