Reputation: 4683
My coworker created a new repo, and on their machine loading the Google JS API loads no problem, but when I try to run gapi.client.init
it returns the error below.
{
"error" : "invalid_request",
"error_description" : "invalid login_hint."
}
When I look at the request on the network, it sends a string for the value of login_hint
as a query string parameter, but I don't have that string anywhere in my codebase.
login_hint:AJDLj6...iriMjPL4JkmR_A
If I create a new set of credentials from the Google API console and use the new client ID it works as I would expect it to. But using the existing set of credentials causes an error, without changing anything else.
My code looks like this:
export class GoogleApiService {
CLIENT_ID: string = '<removed>.apps.googleusercontent.com';
DISCOVERY_DOCS = ['<removed>'];
SCOPES = '<removed>';
constructor() {
window['initGapi'] = (ev) => {
this.handleClientLoad();
};
this.loadScript();
}
loadScript() {
let script = document.createElement('script');
script.src = 'https://apis.google.com/js/api.js?onload=initGapi';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
}
handleClientLoad() {
gapi.load('client:auth2', this.initClient.bind(this));
}
initClient() {
gapi.client.init({
discoveryDocs: this.DISCOVERY_DOCS,
clientId: this.CLIENT_ID,
scope: this.SCOPES
}).then(() => {
console.log('loaded');
},
(err) => console.error(err));
}
}
I'm not specifying the login_hint, so why is that being sent in the request to Google? Why is it incorrect and how can I prevent the error message from occurring?
Upvotes: 1
Views: 1135
Reputation: 4683
For what it's worth, I ended up logging out of my Google account, clicking on the signup link in my app, and in the popup window, signed into my Google account, and it now it all works and I am unable to reproduce. Not sure what caused it originally, but that was my solution.
Hopefully my users never encounter this issue.
Upvotes: 1