Skip to content

Cannot log out from GooglePlus Auth. Homepage keeps calling its GooglePlus callback #316

@epetxepe

Description

@epetxepe

Hi all,

I've correctly implemented the login with GooglePlus, but once I signed up with an account, I'm not able to logout / disconnect correctly, and use local or other Google accounts.

I'm using the login from the example:

            <script type="text/javascript">                    
                     var signInCallback = function (result) {
                    if (result['error']) {
                      alert('An error happened:', result['error']);
                    } else {
                      $('#code').attr('value', result['code']);
                      $('#at').attr('value', result['access_token']);
                      $('#google-plus').submit();
                    }
                };                    
               </script>
                  <script type="text/javascript">
                   (function () {
                       var po = document.createElement('script');
                       po.type = 'text/javascript';
                       po.async = true;
                       po.src = 'https://plus.google.com/js/client:plusone.js?onload=start';
                       var s = document.getElementsByTagName('script')[0];
                       s.parentNode.insertBefore(po, s);
                   })();
                    </script>
                  <li role="presentation">
                 <form id="google-plus" method="post" action="{% url "social:complete" backend="google-plus" %}">{% csrf_token %}
                    <input id="at" type="hidden" name="access_token" value="" />
                    <input id="code" type="hidden" name="code" value="" />

                    <div id="signinButton">
                      <span class="g-signin" data-scope="{{ plus_scope }}"
                                             data-clientid="{{ plus_id }}"
                                             data-redirecturi="postmessage"
                                             data-accesstype="offline"
                                             data-cookiepolicy="single_host_origin"
                                             data-callback="signInCallback">
                      </span>
                    </div>
               </form>
               </li>`

I've tried for logout both

url(r'^logout/$', 'django.contrib.auth.views.logout', {'next_page': '/'},  name='logout'),

and my own view

def logout(request):
    """Logs out user"""
    auth_logout(request)
    return redirect('/')
    #url(r'^logout', 'siteLogic.views.logout', name='logout'),

Regarding disconnect, it seems it works well since no association is found in the following code once executed the following

   <div class="social">
        {% for sublist in available_backends|social_backends %}
          <div class="row">
            {% for name, backend in sublist %}
              {% associated backend %}
              {% if association %}
                <form class="disconnect-form" action="{% url "social:disconnect_individual" backend=association.provider association_id=association.id %}" method="post">{% csrf_token %}
                  <button type="submit" name="{{ backend|backend_class }}" class="btn btn-danger">Disconnect {{ backend|backend_name }}</button>           
                </form>
              <!--{% else %}-->
              <!--  <a class="col-md-2 btn btn-default" name="{{ backend|backend_class }}" href="{% url "social:begin" backend=name %}">-->
              <!--    <i class="fa fa-{{ name|icon_name }}"></i>-->
              <!--    {{ backend|backend_name }}-->
              <!--  </a>-->
              <!--{% endif %}-->
            {% endfor %}
          </div>
        {% endfor %}

But once I load the homepage with the login code, it automatically signs in with the initial Google account, without letting me use local accounts or another Google account.

I've tried googling and stackoverflow without much luck and I'm stuck, so help is appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions