私の同僚が新しいリポジトリを作成しました。そのマシンでGoogle JS APIを読み込んでも問題はありませんが、gapi.client.init
を実行しようとすると、GoogleのJavaScript APIがクライアントの初期化でエラーを返す
{
"error" : "invalid_request",
"error_description" : "invalid login_hint."
}
私は、ネットワーク上の要求を見てみると、それはクエリ文字列パラメータとしてlogin_hint
の値の文字列を送信しますが、私はどこでも私のコードベースでその文字列を持っていません。
login_hint:AJDLj6...iriMjPL4JkmR_A
私は、GoogleのAPIコンソールから資格情報の新しいセットを作成し、私はそれが期待どおりに動作新しいクライアントIDを使用している場合。しかし、既存の資格情報を使用すると、何も変更せずにエラーが発生します。
私のコードは次のようになります。
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));
}
}
私はlogin_hintを指定していないよ、なぜGoogleにリクエストで送信されていること?なぜそれが間違っていて、どうやってエラーメッセージが出るのを防ぐことができますか?