无法使用omniauth-instagram进行身份验证,client_id缺失 [英] Unable to authenticate with omniauth-instagram, client_id missing
问题描述
我使用OmniAuth同时使用Twitter和Instagram进行身份验证。 Twitter运行良好。
当我使用/ auth / instagram请求开始验证过程时,OmniAuth不在授权标头中包含client_id。
我将OmniAuth初始化为:
Rails.application.config.middleware.use OmniAuth :: Builder do
提供者:twitter,ENV.fetch('TWITTER_CONSUMER_KEY'),ENV.fetch('TWITTER_CONSUMER_SECRET')
提供者:instagram,ENV.fetch('INSTAGRAM_CLIENT_ID'),ENV.fetch('INSTAGRAM_CLIENT_SECRET')
end
当我发送/ auth / instagram请求时,它会返回:
{code:400,error_type:OAuthException,
error_message:您必须包含有效的client_id ,response_type和redirect_uri参数}
并显示请求uri,但不包含我的client_id:
https://www.instagram.com/oauth/authorize?client_id=&redirect_uri=http://demo.herokuapp.com/ AUTH /中stagram / callback& response_type = code& scope = basic& state = 952ced9482ccf34faf3e09cffd40f59548f3c5a539499723
任何帮助将不胜感激。 您的 ENV
变量可能未在时间/之后加载您的初始化程序已加载。尝试用实际的字符串替换它们,看看是否有效。不要将它提交给公众回购...相信我,如果你这样做会很烦人。
我是 dotenv 。我使用 rails-now
版本在初始化器中加载ENV变量。
$ b
gem' dotenv-rails',:require => 'gentfile'中的'dotenv / rails-now'
引用如下: ENV ['INSTAGRAM_ID']
I am authenticating using OmniAuth with both Twitter and Instagram. Twitter is working well.
When I start the authentication process with the /auth/instagram request, OmniAuth is not including the client_id in the authorization header.
I have initialized OmniAuth as:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ENV.fetch('TWITTER_CONSUMER_KEY'), ENV.fetch('TWITTER_CONSUMER_SECRET')
provider :instagram, ENV.fetch('INSTAGRAM_CLIENT_ID'), ENV.fetch('INSTAGRAM_CLIENT_SECRET')
end
When I send the /auth/instagram request, it returns:
{"code": 400, "error_type": "OAuthException",
"error_message": "You must include a valid client_id, response_type, and redirect_uri parameters"}
and shows the request uri without my client_id:
https://www.instagram.com/oauth/authorize?client_id=&redirect_uri=http://demo.herokuapp.com/auth/instagram/callback&response_type=code&scope=basic&state=952ced9482ccf34faf3e09cffd40f59548f3c5a539499723
Any help would be appreciated.
Your ENV
variables are probably not being loaded in time / after your initializer is loaded. Try replacing them with the actual strings and see if that works. Don't commit that to a public repo... trust me it's annoying to remove if you do.
I am a fan of dotenv. I use the rails-now
version to load ENV vars in initializers.
gem 'dotenv-rails', :require => 'dotenv/rails-now'
in Gemfile
reference like: ENV['INSTAGRAM_ID']
这篇关于无法使用omniauth-instagram进行身份验证,client_id缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!