Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change POST request to url #142

Open
Alenorze opened this issue Apr 3, 2018 · 5 comments
Open

Change POST request to url #142

Alenorze opened this issue Apr 3, 2018 · 5 comments

Comments

@Alenorze
Copy link

Alenorze commented Apr 3, 2018

image

satellizer had such requests, but here they are slightly different

image

Is it possible to bring them to the first value?

@ronzeidman
Copy link
Owner

In previous versions they were the same but it was hard to understand what was actually sent to the server. I changed it to be this way in the latest version. authorizationData is the actual data that was sent to the authorization endpoint, oauthData is the data received from the authorization endpoint and userData is the additional data you've specified. This is different from the original satellizer that did some kind of mege of everything but I think it's better organized and more predictable.

@Alenorze
Copy link
Author

Alenorze commented Apr 4, 2018

Yes, this is the right decision, but can tell me how to bring these headlines to that value, just on the backend this module and it does not work for another

@ronzeidman
Copy link
Owner

You can merge all of the object to a single one, but there will also be some name changes (snake-case to camel-case in some variables and the "scope" variable is concatinated in the authorizationData in the way defined by the provider settings.
first try doing something like:

Object.keys(req.body).reduce((acc, key) => ({...acc, ...req.body[key]}), {}) //this will merge every key to every value;

or if you want a less general and more understandable code

{ ...req.body.authorizationData, ...req.body.oauthData, ...req.body.userData }

if you have missing properties or properties in the wrong shape after that you'll have to try and fix each one of them manually.

@navneet35371
Copy link

@ronzeidman Hey, I can see your decision to semantically distribute the keys but it breaks some of the libraries out there. Like django-rest-auth which tries to fetch from request body directly.

https://github.com/Tivix/django-rest-auth/blob/master/rest_auth/registration/serializers.py#L85

Anyways, Can you explain the above solution a bit? or a example app maybe?

@ronzeidman
Copy link
Owner

@navneet35371 I see what you mean, maybe it should be configurable. Anyway in the meantime can you add a simple middleware for the routes handled by the django-rest-auth library to merge the body's properties (probably you only need to merge the oauthData with the userData)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants