Skip to content

A few fixes, cleaned up in nice commits #95

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

Merged
merged 10 commits into from
Aug 14, 2015
Merged

A few fixes, cleaned up in nice commits #95

merged 10 commits into from
Aug 14, 2015

Conversation

philippeluickx
Copy link
Contributor

Based on my own needs and a few issues.

@mateusz-sikora mateusz-sikora merged commit 64ab8be into Tivix:master Aug 14, 2015
@ghost
Copy link

ghost commented Sep 8, 2015

@philippeluickx Thank you for your great work! Did you get it work with https://github.com/sahat/satellizer?
I tried it with the following satellizer settings (DRF app running on localhost), but it didn't work:

$authProvider.facebook({
        url: 'http://127.0.0.1:8000/rest-auth/facebook/',
        clientId: 'MY-FB-CLIENT-ID'
    });

@philippeluickx
Copy link
Contributor Author

Hey @ClairePhila !
I got everything running smoothly on my side. However I have a few more settings, something here might point you in the right direction?

$authProvider.tokenName = 'key';
$authProvider.authToken = 'Token';
$authProvider.baseUrl = apiUrl;
$authProvider.loginUrl = 'auth/login/';
$authProvider.signupUrl = 'auth/registration/';
$authProvider.loginRedirect = '';

$authProvider.facebook({
  clientId: facebookClientId,
  url: 'auth/facebook/',
});

@ghost
Copy link

ghost commented Sep 8, 2015

Hi @philippeluickx !
Thank you very much for your help, but this doesn't work for me either. In your case, is the redirect ('auth/facebook/') calling the client (satellizer) or the server (django-rest-auth)? I do still not get the coincidence of satellizer and django-rest-auth, because both a django user has to be created and this user has to be set in satellizer.

Do you no a sample project using both technologies?

@philippeluickx
Copy link
Contributor Author

The redirect needs to be set on both the frontend (satellizer) and backend, the same value. Check out the docs in the code at https://github.com/Tivix/django-rest-auth/blob/master/rest_auth/registration/views.py#L98

Make sure your facebook settings are correct too.

@ghost
Copy link

ghost commented Sep 10, 2015

Thank you again, @philippeluickx !
Now, it almost seems to work, despite of the fact that the Facebook redirect is a GET to '/auth/facebook'. But since the SocialLoginView is a LoginView, it only accepts POST requests (https://github.com/Tivix/django-rest-auth/blob/master/rest_auth/views.py#L52). I'm so sorry, but I think I still didn't get it right.

@philippeluickx
Copy link
Contributor Author

The redirect value is just a common agreed value. If I remember correctly, it does not actually do a redirect to that page.

My front-end is pretty simple, this should work:

    /**
    * @name authenticate
    * @desc authenticate a user with a social provider
    * @memberOf application.authentication.controllers.LoginController
    */
    function authenticate(provider) {
      $auth.authenticate(provider)
      .then(function(response) {
          $state.transitionTo('home');
      })
      .catch(function(response) {
      });
    };

I assume there is a 2-step process:

  1. GET the code from FB
  2. POST the code to your own backend.

scream4ik pushed a commit to scream4ik/django-rest-auth that referenced this pull request Oct 8, 2020
Add drf template auth customization
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

Successfully merging this pull request may close these issues.

4 participants