Comments (23)
Looks quite similar to Google OAuth2 implementation, take a look to it, it should be easy to mimic.
from django-social-auth.
For OAuth2 is important the callback url and the domain from I testing the code?
Because in local I'm using 127.0.0.1 but in callback and in server name settings I have used another domains.....
Must i use the same domain like in facebook login testing?
Now i receive in the query string:
?error=invalid_client
and this:
HTTPError: HTTP Error 400: Bad Request
Thanks in advance omab
from django-social-auth.
Depends on the site. Some providers enforce that the domain from where the request is made must be the same as the one defined in the app configuration, others don't, but seems that foursquare is checking it.
An easy workaround is to serve the same domain from localhost, for example, let's suppose that the domain used in the Foursquare app configuration was example.com
-
Add example.com to /etc/hosts
127.0.0.1 example.com
-
Define Django SITE_URL to use the desired domain
SITE_URL = 'http://example.com'
-
Run the server, and open it in your browser using http://example.com:8000/. The redirect from Foursquare might lack the port number and that will pop a 404 error on your browser, just add :8000 to the URL and it should work.
from django-social-auth.
Yes, i know that workaround, thanks. :-)
Can you take a look on this: http://dpaste.com/hold/543641/ ?
The authentication work:
/accounts/login/foursquare/ redirect to:
for asking the permission, then after accepting permission the foursquare server redirect to:
http://myapp.com/accounts/complete/foursquare/?code=K**FBN34A
But now, i don't know how i can complete the authorization and why access_token is Null.
Can you help me?
Thanks!
from django-social-auth.
cgi.parse_qs parses query strings. Foursquare responds with a JSON-formatted response, so it should be parsed with simplejson.
from django-social-auth.
Looking at your code, seems that you are inheriting from BaseOAuth instead of BaseOAuth2 (https://github.com/omab/django-social-auth/blob/master/social_auth/backends/__init__.py#L628), that should simplify and fix your issues, OAuth2 standard defines responses as JSon strings and they are decoded properly (https://github.com/omab/django-social-auth/blob/master/social_auth/backends/__init__.py#L663)
from django-social-auth.
Ok, i have fixed.
Now i receive these error:
http://dpaste.com/543811/plain/
The code updated is:
http://dpaste.com/hold/543812/
Thanks for the support guys.
from django-social-auth.
Could you share the JSON server response?
from django-social-auth.
Yes, it's this:
{'access_token': 'R0SMPBGO2OGYY0DZPVGM*******O'}
from django-social-auth.
Only access_token? The code that raises the KeyError is trying to get an 'id' entry from the server response, that ID is used to identify the current user with the provider. But you can override the method to suit the foursquare case, in google I needed to override it to use the email address https://github.com/omab/django-social-auth/blob/master/social_auth/backends/google.py#L50, check the details and response data, it might have some value that's unique for current user.
from django-social-auth.
Now seems to work, but there is another problem.
After authorization..
if i disconnect my account (logout) /accounts/logout/ and i want to re-login with foursquare, it ask to me every time the window for asking the permission..
Now i'm using:
https://foursquare.com/oauth2/authorize
?client_id=YOUR_CLIENT_ID
&response_type=code
&redirect_uri=YOUR_REGISTERED_REDIRECT_URI
If i use:
https://foursquare.com/oauth2/authenticate
?client_id=YOUR_CLIENT_ID
&response_type=code
&redirect_uri=YOUR_REGISTERED_REDIRECT_URI
After the login the foursquare server don't reply any, 'error when loading the page'.. but the first auth work correctly.
The code is this:
http://dpaste.com/hold/544013/
Who can help me? :-)
Thanks!
from django-social-auth.
Mmm... I didn't understood you, are you getting an error or not? Which is the error?
from django-social-auth.
Sorry for my bad english.
The problem is this:
The foursquare server asks me the permissions for the login every time, instead that only the first time.
Understand?
There are no errors..
from django-social-auth.
No prob at all, it's not my main language, so that makes things worse :D
What happens when you change the service to "/oauth2/authenticate"? Twitter does the same, /authorize/ asks user permission every time, while /authenticate/ only asks once.
from django-social-auth.
If I change to /authenticate/ the system redirect here:
but the link not work :(
Error connection.
from django-social-auth.
This code http://dpaste.com/hold/544082/ worked properly for me, it's a simplification from your last code, I've removed the overridden functions because they weren't needed at all. It worked with /authorize/ and /authenticate/ properly.
You need to add this two settings to your local_settings or what ever place you keep them::
FOURSQUARE_CONSUMER_KEY = 'YOUR_CONSUMER_KEY'
FOURSQUARE_CONSUMER_SECRET = 'YOUR_CONSUMER_SECRET_KEY'
I'll merge your work if you create a fork of the project and add this backend.
from django-social-auth.
Thanks, but now return to me: ?error=redirect_uri_mismatch
whit this error:
http://dpaste.com/hold/544089/
Must I set it?
Thanks..another ;)
from django-social-auth.
That's because Foursquare is checking the referer url with the one you defined on their app. I've defined http://myapp.com:8000/complete/foursquare/ as redirect on foursquare site, and check the site locally opening http://myapp.com:8000/ (previous /etc/hosts workaround).
from django-social-auth.
Oh yeah!
My error was
Callback URL http://myapp.com:8000/complete/foursquare/
instead of
Callback URL http://myapp.com:8000/accounts/complete/foursquare/
In the foursquare settings :)
Thanks Thousands omab! Seems to work all correctly!
I'll create the fork soon
from django-social-auth.
Ok, created :)
This is my first fork.. i must exercise with git because this is the first time that i use it :)
https://github.com/bedspax/django-social-auth
I'v mistake?
Let me know.
from django-social-auth.
The fork is OK, but contrib backends should be on backends/contrib directory, could you move it?
from django-social-auth.
Moved! :-)
from django-social-auth.
Merged https://github.com/omab/django-social-auth/tree/4f53065e1b42da98fc3f241407e68ada0b1922c5
Thanks
from django-social-auth.
Related Issues (20)
- Facebook: Authentication process canceled
- link to documentation does not work HOT 1
- 401 Client Error: Unauthorized for url: https://oauth.vk.com/access_token HOT 4
- KeyError at /complete/facebook/ ---- 'access_token' HOT 5
- Read The Docs 404 HOT 2
- Cannot resolve keyword 'response' into field. Choices are:
- Documentation link is broken HOT 1
- LinkedIn v2 update
- Manual Create User with access Token HOT 1
- Link to documentation is broken HOT 4
- Disable firstname, lastname field
- Documentation link leads to ReadTheDocs template
- social_core.exceptions.AuthFailed: Authentication failed: SAML login failed: ['invalid_response'] HOT 1
- Token POST request hangs with ASGI
- create_user is not getting called HOT 1
- pyhton3 to python
- It is not compatible in Django version 4 or later
- What about Azure AD?
- linkedin complete login step is stuck
- Is it possible to support two different Google Auth app ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-social-auth.