How to setup oauth2 SSO using auth-backends plugin

Hello everyone,
I’m trying to connect my own marketing site to my open edx instance using auth-backends.
I’ve added an application and set these values on my site:

INSTALLED_APPS = INSTALLED_APPS + ['social_django']

# Generic OAuth2 variables irrespective of SSO/backend service key types.
OAUTH2_PROVIDER_URL = 'http://edx.devstack.lms:18000/oauth2'

# OAuth2 variables specific to social-auth/SSO login use case.
SOCIAL_AUTH_EDX_OAUTH2_KEY = "mktg-client-id"
SOCIAL_AUTH_EDX_OAUTH2_SECRET = "mktg-client-secret"
SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT = "http://localhost:18000"
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = "http://localhost:18000"
SOCIAL_AUTH_REDIRECT_IS_HTTPS = False
SOCIAL_AUTH_STRATEGY = "auth_backends.strategies.EdxDjangoStrategy"

AUTHENTICATION_BACKENDS = (
    'auth_backends.backends.EdXOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

Now when I reach the LMS and login, it redirects me to my site with this parameter included in the query string:

error=invalid_scope

I didn’t define any scope in my settings. Requested scopes is by default: user_id+profile+email

Any help is really appreciated

1 Like

Could you kindly tell me that which version of auth-backends plugin can I use to connect my django site to an ironwood.master instance of Open edX?

Hi @mahyard were you able to find out where the scopes are defined?

Hi @Gaurav_Ojha
I wasn’t able to find out. I guess there was a problem with my instance version (ironwood.master) and in a small try to upgrade to master I was unsuccessful again. finally I fall back to the old method (OIDC) but it may be fixed on master now.
tell us about your experience.

Actually I didn’t find success even the OIDC way. I’m actually trying to make the credentials service to work and the error is same as what you received i.e. invalid_scope.

The ecommerce and insights services work fine with OIDC

@mahyard @Gaurav_Ojha did you both manage to solve this issue?

No @oma0256 I gave up!

hi @oma0256
I had no activity on this since my last reply

I faced same issues and found some solution :slight_smile:
Open you OAuth provider ( which is lms in edx case) and open https://xxxx.com/admin/oauth_dispatch/applicationaccess/ and set scope user_id,profile,email and it works correctly then after.

4 Likes

Ah, perfect! I had the same problem. And in my case, all I had to put in the scope field in OAuth Dispatch was user_id.

1 Like