Skip to content
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

Error to set up the AUTH #31

Open
cavalerosi opened this issue May 22, 2024 · 5 comments
Open

Error to set up the AUTH #31

cavalerosi opened this issue May 22, 2024 · 5 comments

Comments

@cavalerosi
Copy link

Please provide us with the following information:
When I'm trying to create An AUTH object using scopes I getting the error
TypeError: __init__() got an unexpected keyword argument 'scopes'
Also getting error when trying to access Auth' object has no attribute 'get_token_for_user'

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 8, 10, or 11. Linux (which distribution). macOS (Mojave? Catalina? Big Sur? Monterey?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

@surfgreendev
Copy link

I face the same error, any updates?

@nickcounts
Copy link

Removing the scopes argument allowed me to launch the Django test server, it forwards me to the sign in page, I select my user, and then it says "Have an admin account? Sign in with that" or "Return to the application without granting consent"

Not sure if that's on the Azure app registration side or something to do with the scope configuration.

AUTH = Auth(
    os.getenv('CLIENT_ID'),
    client_credential=os.getenv('CLIENT_SECRET')
    redirect_uri=os.getenv('REDIRECT_URI'),
    # scopes=os.getenv('SCOPE', "").split(),
    authority=os.getenv('AUTHORITY'),
)

@Micrified
Copy link

Bumping this. Seeing the exact same problem:

Traceback (most recent call last):
  File "/Users/micrified/src/django/ms/django-web-app/manage.py", line 22, in <module>
    main()
  File "/Users/micrified/src/django/ms/django-web-app/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Users/micrified/src/django/ms/django-web-app/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/micrified/src/django/ms/django-web-app/.venv/lib/python3.9/site-packages/django/core/management/__init__.py", line 382, in execute
    settings.INSTALLED_APPS
  File "/Users/micrified/src/django/ms/django-web-app/.venv/lib/python3.9/site-packages/django/conf/__init__.py", line 102, in __getattr__
    self._setup(name)
  File "/Users/micrified/src/django/ms/django-web-app/.venv/lib/python3.9/site-packages/django/conf/__init__.py", line 89, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/micrified/src/django/ms/django-web-app/.venv/lib/python3.9/site-packages/django/conf/__init__.py", line 217, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/micrified/src/django/ms/django-web-app/mysite/settings.py", line 18, in <module>
    AUTH = Auth(
  File "/Users/micrified/src/django/ms/django-web-app/.venv/lib/python3.9/site-packages/ms_identity_python/django.py", line 38, in __init__
    super(Auth, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'scopes'

Fresh clone off GitHub, and following the documentation exactly.

@shortydutchie
Copy link

shortydutchie commented Nov 20, 2024

It looks like Auth inherits from WebFrameworkAuth, and latter has no scopes keyword.

From what I can see the 'scopes' should be removed from the instantation of Auth in settings.py.

Scopes are used in the call to Auth.login() and Auth.get_token_for_user() (latter is used in views.py)

  1. Remove the scopes keyword from the Auth instantiation in settings.py
  2. the other error is the "identity" bit that is added to INSTALLED_APPS. This should be changed to "ms_identity_python"

@see7e
Copy link

see7e commented Dec 19, 2024

Same issue, as I've said at #45, tried to add the **kwargs arguments at WebFrameworkAuth to avoid the crash at the construction of the class, but it falls back to the other listed issue of the INSTALLED_APPS. Other problem that I've noticed is with the "tests"...

# I don't know how to create a dummy Django app on-the-fly, here we do this instead

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

No branches or pull requests

6 participants