Search code examples
openedxmfe

how to do google login in tutor mfe sign in page


I want to do sign up and sign in using google in tutor mfe . can anyone help me on this?

I set the below two value as True in tutor_plugins/myplugin.py but it is not working

ENABLE_COMBINED_LOGIN_REGISTRATION = True ENABLE_THIRD_PARTY_AUTH = True


Solution

    1. Firstly you need to create google secret-key and ID-
      https://support.google.com/cloud/answer/6158849?hl=en#:~:text=Go%20to%20the%20Google%20Cloud%20Platform%20Console%20Credentials%20page.,to%20add%20a%20new%20secret.
    2. Create plugin of google credential for configuration.
    => mkdir -p "$(tutor plugins printroot)"
    => touch "$(tutor plugins printroot)/third-party-auth.py"
    

    copy and paste below contents in file.

    name: third-party-auth
    version: 1.0.0
    patches:
      common-env-features: |
        "ENABLE_THIRD_PARTY_AUTH": true
      openedx-auth: |
        "SOCIAL_AUTH_OAUTH_SECRETS": {"google-oauth2": "client-secret-from-google"}
      lms-env: |
        "THIRD_PARTY_AUTH_BACKENDS": ["social_core.backends.google.GoogleOAuth2"]
    

    Then, go to “Provider Configuration (OAuth)” in your Django admin panel:

    • Home › Third-party authentication › Provider Configuration (OAuth)
    • URL: admin/third_party_auth/oauth2providerconfig/
    • Click “ADD PROVIDER CONFIGURATION (OAUTH)” to add your provider.

    We use these settings, but your might be slightly different.

    1. Icon class: fa-google
    2. Skip registration form
    3. Skip email verification
    4. Send welcome email
    5. Visible
    6. Backend name: google-oauth2
    7. Client ID: Enter client ID from the OAuth2 provider
    8. Client Secret: (leave blank! The value is in the plugin.)

    Use the “Enabled” checkbox at the top of the page to enable or disable the OAuth2 login button.

    That’s it!