Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在本地使用Omniauth Github验证Rails应用程序_Ruby On Rails_Ruby_Ruby On Rails 4_Github_Omniauth - Fatal编程技术网

Ruby on rails 在本地使用Omniauth Github验证Rails应用程序

Ruby on rails 在本地使用Omniauth Github验证Rails应用程序,ruby-on-rails,ruby,ruby-on-rails-4,github,omniauth,Ruby On Rails,Ruby,Ruby On Rails 4,Github,Omniauth,我正在本地开发模式下使用GitHub对用户进行身份验证 我用的是Rubygem 我在config/initializers/omniauth.rb中有下面的代码 OmniAuth.config.logger = Rails.logger Rails.application.config.middleware.use OmniAuth::Builder do provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], {

我正在本地开发模式下使用GitHub对用户进行身份验证

我用的是Rubygem

我在config/initializers/omniauth.rb中有下面的代码

OmniAuth.config.logger = Rails.logger

Rails.application.config.middleware.use OmniAuth::Builder do
 provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'],
    {
      :client_options => {
        :site => 'https://github.com/api/v3',
        :authorize_url => 'https://github.com/login/oauth/authorize',
        :token_url => 'https://github.com/login/oauth/access_token',
      }
    }
end
在视图布局中,我有

<%= link_to "Sign in with Github", "/auth/github" %>
我已经在github注册了新的应用程序 主页URL: ,授权回调URL

单击使用Github登录后,我发现以下错误

http://localhost:3000/callback?error=redirect_uri_mismatch&error_description=The redirect_uri MUST match the registered callback URL for this application.&error_uri=https://developer.github.com/v3/oauth/#redirect-uri-mismatch&state=14216a2416431297d9690e68efe0723a03aa7a1eaee51db3

请帮助我为站点设置正确的值,授权\u url、令牌\u url在本地系统中工作。

从描述到目前为止,
rake routes | grep callback
please,我认为您需要将注册的回调url从
http://localhost:3000/callback
http://localhost:3000/auth/github/callback
。看看它是否有效。谢谢你的退出解决方案,是的,你是对的,它确实有效。但我又犯了一个新的错误。请查找在2017-01-03 13:54:58+0530(github)回调阶段启动的针对::1的“/auth/github/callback?code=9b83c44089bfffa0296c&state=648895e88fd34b8c9c43c3de95c8033da49f99d8dbe17182”启动的日志。(github)身份验证失败!无效的_凭据:OAuth2::Error,未找到:{“Error”:“未找到”}OAuth2::Error(未找到:{“Error”:“未找到”}):OAuth2(1.3.0)lib/OAuth2/client.rb:119:“请求”中
http://localhost:3000/callback?error=redirect_uri_mismatch&error_description=The redirect_uri MUST match the registered callback URL for this application.&error_uri=https://developer.github.com/v3/oauth/#redirect-uri-mismatch&state=14216a2416431297d9690e68efe0723a03aa7a1eaee51db3