开发者

I'm forced to redirect to logo page in Facebook App IFRAME

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,offl开发者_如何学Cine_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


This is because of redirting user without permission you can easly solve it by adding target="_top" to link.

<a href="url" target="_top">login</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜