我正在尝试使用google或任何其他社交网络登录。我已经使用http://r12---sn-cvh7kn7y.googlevideo.com/videoplayback?sparams=dur,ei,expire,id,i
跟踪了Codeplace教程我遇到了以下问题
Error: invalid_request
Missing required parameter: client_id
Learn more
Request Details
access_type=offline
scope=email profile
response_type=code
redirect_uri=http://localhost:9292/auth/google_oauth2/callback
state=2f6a1b1d2e0a2fb1c75647a6d145efa907c3ee9038a8bb54
client_id=
我的相关代码是 - omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :google_oauth2,ENV['238730796202-.com'],ENV['TyqJqfiOJLoLgqRRGgTIynxt']
provider :facebook, ENV['1585034338471672'],ENV['3211b382a1636bdc747d37921aab2a90']
end
sessioncontroller.rb
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
puts auth
session[:omniauth] = auth.except('extra')
user = User.sign_in_from_omniouth(auth)
session[:user_id] = user_id
redirect_to root_url, notice:"Sign In"
end
def destroy
session[:user_id] = nil
session[:omniauth] = nil
redirect_to root_url, notice:"Sign OUT"
end
end
user.rb
class User < ActiveRecord::Base
def self.sign_in_from_omniouth(auth)
find_by(provider: auth['provider'], uid: auth['uid'])||
create_user_from_omniauth(auth)
end
def self.create_user_from_omniauth(auth)
create(
provider:auth['provider'],
uid:auth['uid'],
name:auth['info']['name']
)
end
end
end
任何人都可以帮助我吗?
答案 0 :(得分:0)
根据遇到的错误,int[] iconArray={R.drawable.icon1,R.drawable.icon2,.....};
缺失。
尝试documentation中提供的基本步骤,通过此操作从Google API控制台获取OAuth 2.0凭据:
访问Google API控制台以获取OAuth 2.0凭据,例如Google和您的应用程序都知道的
client_id
和client ID
。
请尝试通过Google API控制台启用“通讯录API”和“Google+ API”。如此GitHub post中所述,如果未启用这些功能,您将收到client secret
,指出在您尝试进行身份验证时未配置访问权限。
请尝试浏览指定的GitHub帖子OmniAuth Google OAuth2 Strategy以获取重要详情。