Processing permissions with a request signed by koala

I am creating a canvas application with rails and authorization authorization on a koala, but I do not know if I am doing the right thing. How to get permissions from the user? Now I am doing something like the code below, but I know that this is wrong, because when the user is redirected, he needs to click the "Access to Facebook" button before giving permission ...

before_filter :parse_signed_request  
def parse_signed_request  
    @oauth = Koala::Facebook::OAuth.new('callback')  
    @signed_request = @oauth.parse_signed_request(params[:signed_request])  
    if @signed_request["user_id"]  
        @graph = Koala::Facebook::GraphAPI.new(@signed_request["oauth_token"])  
    else  
        redirect_to @oauth.url_for_oauth_code(:permissions => "publish_stream");  
    end  
end
+3
source share
2 answers

You cannot redirect, just send script: back <script type="text/javascript">top.location.href='...'</script>. You can find more information here: http://developers.facebook.com/docs/guides/canvas/

+1
source

Quora. : , Ruby on Rails. , API.

0

Source: https://habr.com/ru/post/1793429/


All Articles