我已经尝试了此问题的每种解决方案。
1。)通过更新omniauth的所有3个宝石
bundle update omniauth-google-oauth2 omniauth-facebook omniauth
2。)通过添加token_params:{parse::json}
config.omniauth :facebook, ENV['FACEBOOK_OMNIAUTH_CLIENT_ID'], ENV['FACEBOOK_OMNIAUTH_CLIENT_SECRET'], scope: 'public_profile, email', info_fields: 'email,first_name,last_name', token_params: { parse: :json }
3)。通过指定Api版本
config.omniauth :facebook, ENV['FACEBOOK_OMNIAUTH_CLIENT_ID'], ENV['FACEBOOK_OMNIAUTH_CLIENT_SECRET'], scope: 'public_profile, email', info_fields: 'email,first_name,last_name', token_params: { parse: :json },client_options: {
site: 'https://graph.facebook.com/v3.1', # this is the example API version
authorize_url: "https://www.facebook.com/v3.1/dialog/oauth"
}
仍然收到此错误“无效的凭据”
*Started GET "/users/auth/facebook/callback?code=AQDgxIKcfy9bvyQx25Co3KxMPimFt6zbQHbL-Yilk63xustHu_4cBtbhPjbpHq8eeYXG0wiD5FJIrZ5MUwzlc1BIIahXZ8WyYTz5_E1k7C165ttSG7CKK2fDkEa1V_1LcskKZZh-bXy5aVinnPOOoJSzfTN7vz-ZymbxfMr-bT_v3r7WpUjtZtYO3xR8JqBDp9rqB7EScdkYJvDgGqZ0V3w6gLhlCD1ae3xD54_vl04GQB3iBo9WnWlq5Br-JerORZD6qVUnD70_f5jC0diOorWK370uGxOKYwK_LBGfM8B-B_IQsw9IFRvk7u7hq_yaJhAuLRd-3iOrC3A8LDAz9SL6&state=aafc83cc91a92365969edf3f5f65431e2f788dd8aa691607" for 118.67.252.106 at 2018-10-11 17:42:06 +0530
I, [2018-10-11T17:42:07.014448 #8505] INFO -- omniauth: (facebook) Callback phase initiated.
E, [2018-10-11T17:42:07.542530 #8505] ERROR -- omniauth: (facebook) Authentication failure! invalid_credentials: OAuth2::Error, <!DOCTYPE html>
<html lang="en" id="facebook">
<head>
<title>Facebook | Error</title>
<meta charset="utf-8">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="cache-control" content="no-store">
<meta http-equiv="cache-control" content="max-age=0">
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
<meta name="robots" content="noindex,nofollow">
<style>
html, body {
color: #141823;
background-color: #e9eaed;
font-family: Helvetica, Lucida Grande, Arial,
Tahoma, Verdana, sans-serif;
margin: 0;
padding: 0;
text-align: center;
}
#header {
height: 30px;
padding-bottom: 10px;
padding-top: 10px;
text-align: center;
}
#icon {
width: 30px;
}
h1 {
font-size: 18px;
}
p {
font-size: 13px;
}
#footer {
border-top: 1px solid #ddd;
color: #9197a3;
font-size: 12px;
padding: 5px 8px 6px 0;
}
</style>
</head>
<body>
<div id="header">
<a href="//www.facebook.com/">
<img id="icon" src="//static.facebook.com/images/logos/facebook_2x.png" />
</a>
</div>
<div id="core">
<h1 id="sorry">Sorry, something went wrong.</h1>
<p id="promise">
We're working on it and we'll get it fixed as soon as we can.
</p>
<p id="back-link">
<a id="back" href="//www.facebook.com/">Go Back</a>
</p>
<div id="footer">
Facebook
<span id="copyright">
© 2018
</span>
<span id="help-link">
·
<a id="help" href="//www.facebook.com/help/">Help Center</a>
</span>
</div>
</div>
<script>
document.getElementById('back').onclick = function() {
if (history.length > 1) {
history.back();
return false;
}
};
// Adjust the display based on the window size
if (window.innerHeight < 80 || window.innerWidth < 80) {
// Blank if window is too small
document.body.style.display = 'none';
};
if (window.innerWidth < 200 || window.innerHeight < 150) {
document.getElementById('back-link').style.display = 'none';
document.getElementById('help-link').style.display = 'none';
};
if (window.innerWidth < 200) {
document.getElementById('sorry').style.fontSize = '16px';
};
if (window.innerWidth < 150) {
document.getElementById('promise').style.display = 'none';
};
if (window.innerHeight < 150) {
document.getElementById('sorry').style.margin = '4px 0 0 0';
document.getElementById('sorry').style.fontSize = '14px';
document.getElementById('promise').style.display = 'none';
};
</script>
</body>
</html>
Processing by Users::OmniauthCallbacksController#failure as HTML
Parameters: {"code"=>"AQDgxIKcfy9bvyQx25Co3KxMPimFt6zbQHbL-Yilk63xustHu_4cBtbhPjbpHq8eeYXG0wiD5FJIrZ5MUwzlc1BIIahXZ8WyYTz5_E1k7C165ttSG7CKK2fDkEa1V_1LcskKZZh-bXy5aVinnPOOoJSzfTN7vz-ZymbxfMr-bT_v3r7WpUjtZtYO3xR8JqBDp9rqB7EScdkYJvDgGqZ0V3w6gLhlCD1ae3xD54_vl04GQB3iBo9WnWlq5Br-JerORZD6qVUnD70_f5jC0diOorWK370uGxOKYwK_LBGfM8B-B_IQsw9IFRvk7u7hq_yaJhAuLRd-3iOrC3A8LDAz9SL6", "state"=>"aafc83cc91a92365969edf3f5f65431e2f788dd8aa691607"}
Redirected to https://39019a0d.ngrok.io/users/sign_in*
请有人帮我解决此问题。我花了整整一天的时间,而另一天却以相同的方式进行。