我被迫重定向到 Facebook 应用程序 IFRAME 中的徽标页面
我想在 IFRAME(Facebook Apps)中登录 facebook。
注销后转到 http://apps.facebook.com/oauthtwosample/ 并单击“登录”链接。
重定向权限请求对话框页面时,响应标头具有 Location 标头。
Chrome 屏幕截图如下:
http://gyazo.com/0f4988158cb0e0a9f52545374540de96
如果您有任何想法,请告诉我。
来源:
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
@@client = OAuth2::Client.new(
'xxxxxxxxxxxxx',
'xxxxxxxxxxxxxxxxxxxxxxxx',
:site => 'https://graph.facebook.com'
)
def redirect_uri
uri = URI.parse(request.url)
uri.path = '/auth/facebook/callback'
uri.query = nil
uri.to_s
end
get '/' do
'<a href="/auth/facebook">login</a>'
end
post '/' do
'<a href="/auth/facebook">login</a>'
end
get '/auth/facebook' do
redirect @@client.web_server.authorize_url(
:redirect_uri => redirect_uri,
:scope => 'email,offline_access'
)
end
get '/auth/facebook/callback' do
access_token = @@client.web_server.get_access_token(
params[:code],
:redirect_uri => redirect_uri
)
user = JSON.parse(access_token.get('/me'))
user.inspect
end
I want to login to facebook in IFRAME(Facebook Apps).
Go http://apps.facebook.com/oauthtwosample/ with logoff and click "login" link.
Response header have Location Header when redirect permissions request dialog page.
Chrome screenshot below:
http://gyazo.com/0f4988158cb0e0a9f52545374540de96
If you have any ideas, let me know.
Source:
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
@@client = OAuth2::Client.new(
'xxxxxxxxxxxxx',
'xxxxxxxxxxxxxxxxxxxxxxxx',
:site => 'https://graph.facebook.com'
)
def redirect_uri
uri = URI.parse(request.url)
uri.path = '/auth/facebook/callback'
uri.query = nil
uri.to_s
end
get '/' do
'<a href="/auth/facebook">login</a>'
end
post '/' do
'<a href="/auth/facebook">login</a>'
end
get '/auth/facebook' do
redirect @@client.web_server.authorize_url(
:redirect_uri => redirect_uri,
:scope => 'email,offline_access'
)
end
get '/auth/facebook/callback' do
access_token = @@client.web_server.get_access_token(
params[:code],
:redirect_uri => redirect_uri
)
user = JSON.parse(access_token.get('/me'))
user.inspect
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为未经许可重定向用户,您可以轻松地
通过在链接中添加 target="_top" 来解决它。
This is because of redirting user without permission you can easly
solve it by adding target="_top" to link.