Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 26, 2011 02:39:12

C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django facebook authentication


I am going nuts this should be simple but I keep getting a
verification error every time in my response in the following code. I
double checked my APP_ID and SECRET I try the following code. I'm
using python2.5. Any help appreciated.

def login( request ):

parms = { 'client_id': settings.FACEBOOK_APP_ID,
'redirect_uri': 'http://' + request.get_host() +
request.get_full_path()
}

if 'code' in request.GET:
parms = request.GET
parms = settings.FACEBOOK_APP_SECRET
url = 'https://graph.facebook.com/oauth/access_token?' +
urllib.urlencode(parms)

response = urllib.urlopen(url).read()
pdb.set_trace()
response =cgi.parse_qs(response)

if 'access_token' in response:
access_token = response
graph = GraphAPI( access_token )
profile = graph.get_object("me")
url = reverse('sites')
url = reverse('sites')

else:
parms = 'email,user_location'
url = "https://graph.facebook.com/oauth/authorize?"; +
urllib.urlencode(parms)

return HttpResponseRedirect(url)

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 26, 2011 05:07:39

Matias A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django facebook authentication


Hi,

Is your request.get_host() the same defined in Facebook app settings? (Web site
section if I can recall correctly), facebook doesn't accept 127.0.0.1 as
redirect url and might not accept localhost too.

Check social_auth/backends/facebook.py onhttps://github.com/omab/django-social-authfor an example.

Regards,
Matías

Excerpts from CrabbyPete's message of Wed Jan 26 00:39:05 -0200 2011:
> I am going nuts this should be simple but I keep getting a
> verification error every time in my response in the following code. I
> double checked my APP_ID and SECRET I try the following code. I'm
> using python2.5. Any help appreciated.
>
> def login( request ):
>
> parms = { 'client_id': settings.FACEBOOK_APP_ID,
> 'redirect_uri': 'http://' + request.get_host() +
> request.get_full_path()
> }
>
> if 'code' in request.GET:
> parms = request.GET
> parms = settings.FACEBOOK_APP_SECRET
> url = 'https://graph.facebook.com/oauth/access_token?' +
> urllib.urlencode(parms)
>
> response = urllib.urlopen(url).read()
> pdb.set_trace()
> response =cgi.parse_qs(response)
>
> if 'access_token' in response:
> access_token = response
> graph = GraphAPI( access_token )
> profile = graph.get_object("me")
> url = reverse('sites')
> url = reverse('sites')
>
> else:
> parms = 'email,user_location'
> url = "https://graph.facebook.com/oauth/authorize?"; +
> urllib.urlencode(parms)
>
> return HttpResponseRedirect(url)
--
Matías Aguirre <matiasagui...@gmail.com>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 27, 2011 13:51:34

C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

django facebook authentication


Thanks I figured it out. I should just use request.path I used
request.get_full_path() which returns the whole request including the ?
code=xxx which messed me up.

On Jan 26, 12:07 am, Matias Aguirre <matiasagui...@gmail.com> wrote:
> Hi,
>
> Is your request.get_host() the same defined in Facebook app settings? (Web
> site
> section if I can recall correctly), facebook doesn't accept 127.0.0.1 as
> redirect url and might not accept localhost too.
>
> Check social_auth/backends/facebook.py
> onhttps://github.com/omab/django-social-auth> for an example.
>
> Regards,
> Matías
>
> Excerpts fromCrabbyPete'smessage of Wed Jan 26 00:39:05 -0200 2011:
>
> > I am going nuts this should be simple but I keep getting a
> > verification error every time in my response in the following code. I
> > double checked my APP_ID and SECRET  I try the following code. I'm
> > using python2.5. Any help appreciated.
>
> > def login( request ):
>
> >     parms = { 'client_id': settings.FACEBOOK_APP_ID,
> >               'redirect_uri': 'http://' + request.get_host() +
> > request.get_full_path()
> >             }
>
> >     if 'code' in request.GET:
> >         parms = request.GET
> >         parms = settings.FACEBOOK_APP_SECRET
> >         url = 'https://graph.facebook.com/oauth/access_token?'+
> > urllib.urlencode(parms)
>
> >         response = urllib.urlopen(url).read()
> >         pdb.set_trace()
> >         response =cgi.parse_qs(response)
>
> >         if 'access_token' in response:
> >             access_token = response
> >             graph = GraphAPI( access_token )
> >             profile = graph.get_object("me")
> >             url = reverse('sites')
> >         url = reverse('sites')
>
> >     else:
> >         parms = 'email,user_location'
> >         url = "https://graph.facebook.com/oauth/authorize?"; +
> > urllib.urlencode(parms)
>
> >     return HttpResponseRedirect(url)
>
> --
> Matías Aguirre <matiasagui...@gmail.com>

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 14th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support