librelist archives

« back to archive

weird error with flask-oauth and facebook

weird error with flask-oauth and facebook

From:
Max Ischenko
Date:
2012-06-16 @ 09:05
Hey everyone, 

I haven't been programming for a while; using Flask for my small facebook 
app and chasing one weird error for a couple of weeks now. Please help!

I am using flask-oauth for my canvas-based facebook app. 

I've started with example code here:
https://github.com/mitsuhiko/flask-oauth/blob/master/example/facebook.py

There was a problem with /login though. Since Canvas apps are now HTTPS 
some browsers (Safari) does not redirect correctly in the iFrame, results 
in a blank page. 

http://stackoverflow.com/questions/9100916/blank-canvas-refused-to-display-document-because-display-forbidden-by-x-fram

So I've changed /login code to do client-side redirect:
https://gist.github.com/2940592

It works MOST of the time. 

But from time to time when new user signs up I get an error from 
flask-oauth: Invalid response from Facebook: missing redirect_uri. From 
reading the code, I understood that there must be no facebook_ouathredir 
in the session so when oauth2 callback got callled it cannot find it.

I assume something is wrong with my /login hack. I cannot really debug it 
since it works for me and most of users. And I ran out of friends to test 
it out on. :(

If somebody can help I owe a drink :)


Max


Skype: max.ischenkoCell: +380-50-1660266
You should follow me on Twitter at twitter.com/maxua

Re: [flask] weird error with flask-oauth and facebook

From:
Max Countryman
Date:
2012-06-16 @ 12:59
Hi Max,

Perhaps it might be worth giving rauth a try? (Full disclosure, I'm the 
original author and maintainer of rauth.)

I've whipped up a quick example app that shows a very basic login and 
persistence flow for Facebook users via Flask and rauth: 
https://github.com/litl/rauth/tree/master/examples/facebook

I'm not sure if this fits your needs or not, but I thought I'd put it out 
there. If you have any further questions don't hesitate to ask!

HTH,


Max

On Jun 16, 2012, at 5:05 AM, Max Ischenko wrote:

> Hey everyone,
> 
> I haven't been programming for a while; using Flask for my small 
facebook app and chasing one weird error for a couple of weeks now. Please
help!
> 
> I am using flask-oauth for my canvas-based facebook app. 
> 
> I've started with example code here:
> https://github.com/mitsuhiko/flask-oauth/blob/master/example/facebook.py
> 
> There was a problem with /login though. Since Canvas apps are now HTTPS 
some browsers (Safari) does not redirect correctly in the iFrame, results 
in a blank page. 
> 
http://stackoverflow.com/questions/9100916/blank-canvas-refused-to-display-document-because-display-forbidden-by-x-fram
> 
> So I've changed /login code to do client-side redirect:
> https://gist.github.com/2940592
> 
> It works MOST of the time. 
> 
> But from time to time when new user signs up I get an error from 
flask-oauth: Invalid response from Facebook: missing redirect_uri. From 
reading the code, I understood that there must be no facebook_ouathredir 
in the session so when oauth2 callback got callled it cannot find it.
> 
> I assume something is wrong with my /login hack. I cannot really debug 
it since it works for me and most of users. And I ran out of friends to 
test it out on. :(
> 
> If somebody can help I owe a drink :)
> 
> 
> Max
> 
> 
> Skype: max.ischenko
> Cell: +380-50-1660266
> You should follow me on Twitter at twitter.com/maxua
> 

Re: [flask] weird error with flask-oauth and facebook

From:
Sean Lynch
Date:
2012-06-17 @ 01:13
I'm using Flask-Social (It's built upon Flask-Security, Flask-OAuth,
Flask-Login, Flask-Principal, among others).

http://packages.python.org/Flask-Social/
http://packages.python.org/Flask-Security/

example:
http://flask-social-example.herokuapp.com/
https://github.com/mattupstate/flask-social-example

On Sat, Jun 16, 2012 at 8:59 AM, Max Countryman <maxc@me.com> wrote:

> Hi Max,
>
> Perhaps it might be worth giving rauth a try? (Full disclosure, I'm the
> original author and maintainer of rauth.)
>
> I've whipped up a quick example app that shows a very basic login and
> persistence flow for Facebook users via Flask and rauth:
> https://github.com/litl/rauth/tree/master/examples/facebook
>
> I'm not sure if this fits your needs or not, but I thought I'd put it out
> there. If you have any further questions don't hesitate to ask!
>
> HTH,
>
>
> Max
>
> On Jun 16, 2012, at 5:05 AM, Max Ischenko wrote:
>
>  Hey everyone,
>
> I haven't been programming for a while; using Flask for my small facebook
> app and chasing one weird error for a couple of weeks now. Please help!
>
> I am using flask-oauth for my canvas-based facebook app.
>
> I've started with example code here:
> https://github.com/mitsuhiko/flask-oauth/blob/master/example/facebook.py
>
> There was a problem with /login though. Since Canvas apps are now HTTPS
> some browsers (Safari) does not redirect correctly in the iFrame, results
> in a blank page.
>
> 
http://stackoverflow.com/questions/9100916/blank-canvas-refused-to-display-document-because-display-forbidden-by-x-fram
>
> So I've changed /login code to do client-side redirect:
> https://gist.github.com/2940592
>
> It works MOST of the time.
>
> But from time to time when new user signs up I get an error from
> flask-oauth: Invalid response from Facebook: missing redirect_uri. From
> reading the code, I understood that there must be no facebook_ouathredir in
> the session so when oauth2 callback got callled it cannot find it.
>
> I assume something is wrong with my /login hack. I cannot really debug it
> since it works for me and most of users. And I ran out of friends to test
> it out on. :(
>
> If somebody can help I owe a drink :)
>
>
> Max
>
>
> Skype: max.ischenko
> Cell: +380-50-1660266
> You should follow me on Twitter at twitter.com/maxua
>
>
>

Re: [flask] weird error with flask-oauth and facebook

From:
Kenneth Reitz
Date:
2012-06-16 @ 09:57
This code is horrendous, but it works.

https://github.com/heroku/facebook-template-python

Hope it helps. 

-- 
Kenneth Reitz


On Saturday, June 16, 2012 at 5:05 AM, Max Ischenko wrote:

> Hey everyone, 
> 
> I haven't been programming for a while; using Flask for my small 
facebook app and chasing one weird error for a couple of weeks now. Please
help!
> 
> I am using flask-oauth for my canvas-based facebook app. 
> 
> I've started with example code here:
> https://github.com/mitsuhiko/flask-oauth/blob/master/example/facebook.py
> 
> There was a problem with /login though. Since Canvas apps are now HTTPS 
some browsers (Safari) does not redirect correctly in the iFrame, results 
in a blank page. 
> 
http://stackoverflow.com/questions/9100916/blank-canvas-refused-to-display-document-because-display-forbidden-by-x-fram
> 
> So I've changed /login code to do client-side redirect:
> https://gist.github.com/2940592
> 
> It works MOST of the time. 
> 
> But from time to time when new user signs up I get an error from 
flask-oauth: Invalid response from Facebook: missing redirect_uri. From 
reading the code, I understood that there must be no facebook_ouathredir 
in the session so when oauth2 callback got callled it cannot find it.
> 
> I assume something is wrong with my /login hack. I cannot really debug 
it since it works for me and most of users. And I ran out of friends to 
test it out on. :(
> 
> If somebody can help I owe a drink :)
> 
> 
> Max
> 
> 
> Skype: max.ischenkoCell: +380-50-1660266
> You should follow me on Twitter at twitter.com/maxua (http://twitter.com/maxua)
>