Error: idpiframe_initialization_failed while implementing OAuth 2.0
Error: idpiframe_initialization_failed while implementing OAuth 2.0
我在 Web 应用程序中使用 OAuth 2.0 时遇到此错误。我正在用 React 构建我的应用程序。我也创建了 OAuth 客户端 ID。我正在使用 Google Chrome 浏览器:
{error: 'idpiframe_initialization_failed', details: 'You have created a new client application that use…i/web/guides/gis-migration) for more information.'}
下面是我的 Google 基于反应的网络应用程序中的授权代码:
import React from 'react';
class GoogleAuth extends React.Component {
state = { isSignedIn: null };
componentDidMount() {
window.gapi.load('client:auth2', () => {
window.gapi.client.init({
clientId: '716075642837-kergfh0638hu8iq5dimpgnlc1f08s61r.apps.googleusercontent.com',
scope: 'email'
}).then(() => {
this.auth = window.gapi.auth2.getAuthInstance();
this.setState({isSignedIn: this.auth.isSignedIn.get()})
});
});
}
renderAuthButton() {
if(this.state.isSignedIn === null) {
return <div> I don't know if we are signed in </div>;
} else if(this.state.isSignedIn) {
return <div>I am signed in</div>
} else {
return <div>I am not signed in</div>
}
}
render() {
return <div> {this.renderAuthButton() } </div>;
}
}
export default GoogleAuth;
你必须在范围后添加plugin_name
window.gapi.load('client:auth2', () => {
window.gapi.client.init({
clientId: '716075642837-kergfh0638hu8iq5dimpgnlc1f08s61r.apps.googleusercontent.com',
scope: 'email',
**plugin_name: 'streamy'**
}).then(() => {
this.auth = window.gapi.auth2.getAuthInstance();
this.setState({isSignedIn: this.auth.isSignedIn.get()})
});
});
}```
我在 Web 应用程序中使用 OAuth 2.0 时遇到此错误。我正在用 React 构建我的应用程序。我也创建了 OAuth 客户端 ID。我正在使用 Google Chrome 浏览器:
{error: 'idpiframe_initialization_failed', details: 'You have created a new client application that use…i/web/guides/gis-migration) for more information.'}
下面是我的 Google 基于反应的网络应用程序中的授权代码:
import React from 'react';
class GoogleAuth extends React.Component {
state = { isSignedIn: null };
componentDidMount() {
window.gapi.load('client:auth2', () => {
window.gapi.client.init({
clientId: '716075642837-kergfh0638hu8iq5dimpgnlc1f08s61r.apps.googleusercontent.com',
scope: 'email'
}).then(() => {
this.auth = window.gapi.auth2.getAuthInstance();
this.setState({isSignedIn: this.auth.isSignedIn.get()})
});
});
}
renderAuthButton() {
if(this.state.isSignedIn === null) {
return <div> I don't know if we are signed in </div>;
} else if(this.state.isSignedIn) {
return <div>I am signed in</div>
} else {
return <div>I am not signed in</div>
}
}
render() {
return <div> {this.renderAuthButton() } </div>;
}
}
export default GoogleAuth;
你必须在范围后添加plugin_name
window.gapi.load('client:auth2', () => {
window.gapi.client.init({
clientId: '716075642837-kergfh0638hu8iq5dimpgnlc1f08s61r.apps.googleusercontent.com',
scope: 'email',
**plugin_name: 'streamy'**
}).then(() => {
this.auth = window.gapi.auth2.getAuthInstance();
this.setState({isSignedIn: this.auth.isSignedIn.get()})
});
});
}```