I have enabled third party auth with my external app , Now what i want to achieve is if the user is already registered and verifieid on external app , it should automatically register that user on openedx platform when it try to sign in for the first time. The details that i get from external app does not include full name which is necessary for registration so openedx platform ultimately lands up in a web error.
I already have an idea how to reolve this error. I can add a function in social_auth_pipeline which will create full name from first name and last name.
I want suggestions on how can I resolve this issue using plugin or hook or filter.
I added django app in the lms container and installed it with pip , when i do pip list, it shows up.
Here are the contents
/openedx/edx-platform/requirements/fullnamepipeline/fullnamepipeline/pipeline.py
import logging
logger = logging.getLogger(name)
def add_full_name(strategy, details, *args, **kwargs):
“”"
Social-auth pipeline step: ensure details[‘fullname’] is ‘First Last’.
“”"
logger.warning(“ FULLNAMEPIPELINE CALLED for user %s”, details)
first = (details.get(“first_name”) or “”).strip()
last = (details.get(“last_name”) or “”).strip()
full = f"{first} {last}".strip()
full = “FUll name”
Only set fullname if we actually built something
if full:
Either mutate in place or return an update dict; both are acceptable.
details[“fullname”] = full
return {“details”: details}
return None
requirements/fullnamepipeline/setup.py
from setuptools import setup, find_packages
setup(
name=“fullnamepipeline”,
version=“0.1.0”,
packages=find_packages(),
include_package_data=True,
install_requires=[
“edx-django-utils>=8.0.0”,
“social-auth-core”, # already in edx-platform, but harmless here
],
entry_points={
“lms.djangoapp”: [
“fullnamepipeline = fullnamepipeline.apps:FullNamePipelineConfig”,
],
“cms.djangoapp”: [
“fullnamepipeline = fullnamepipeline.apps:FullNamePipelineConfig”,
],
},
)
**requirements/fullnamepipeline/fullnamepipeline/apps.py
**
from django.apps import AppConfig
from edx_django_utils.plugins.constants import PluginSettings
class FullNamePipelineConfig(AppConfig):
name = “fullnamepipeline”
verbose_name = “Full Name Pipeline”
# Tell edx-platform this plugin has settings to merge
plugin_app = {
PluginSettings.CONFIG: {
"lms.djangoapp": {
"common": {PluginSettings.RELATIVE_PATH: "settings.common"},
},
"cms.djangoapp": {
"common": {PluginSettings.RELATIVE_PATH: "settings.common"},
},
}
}
requirements/fullnamepipeline/fullnamepipeline/settings/common.py
def plugin_settings(settings):
“”"
Insert our step right after the built-in social_details
step.
“”"
anchor = “common.djangoapps.third_party_auth.pipeline.associate_by_email_if_oauth”
step = “fullnamepipeline.pipeline.add_full_name”
pipeline = list(getattr(settings, "SOCIAL_AUTH_PIPELINE", ()))
if step not in pipeline:
try:
i = pipeline.index(anchor)
pipeline.insert(i + 1, step)
except ValueError:
# Fallback: append if anchor not found
pipeline.append(step)
settings.SOCIAL_AUTH_PIPELINE = tuple(pipeline)
requirements/fullnamepipeline/fullnamepipeline/_init_.py