Repository: pennersr/django-allauth

Issue:
0.46.0 Apple provider test broken
Hi! When trying to package 0.46.0 for Arch Linux I ran into failing tests which appear to be pyjwt related:

```
Creating test database for alias 'default'...
System check identified some issues:

WARNINGS:
openid.OpenIDNonce: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
openid.OpenIDStore: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the AppConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

System check identified 2 issues (0 silenced).
....................................................................................................E.E..................................................................................................................................../build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/
tests.py:87: UserWarning: Cannot test provider evernote, no oauth mock
  warnings.warn("Cannot test provider %s, no oauth mock" % self.provider.id)
..................................................................................................................................................................................xx.........................................................................................../build/python-django-allauth/src/python-django-a
llauth-0.46.0/allauth/socialaccount/tests.py:87: UserWarning: Cannot test provider trello, no oauth mock
  warnings.warn("Cannot test provider %s, no oauth mock" % self.provider.id)
./build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/tests.py:55: UserWarning: Cannot test provider trello, no oauth mock
  warnings.warn("Cannot test provider %s, no oauth mock" % self.provider.id)
......................................................................................
======================================================================
ERROR: test_apple_finish (allauth.socialaccount.providers.apple.tests.AppleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/tests.py", line 231, in test_apple_finish
    resp = self.login(self.get_mocked_response())
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/tests.py", line 210, in login
    resp = self.client.get(resp.url)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 742, in get
    response = super().get(path, data=data, secure=secure, **extra)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 396, in get
    return self.generic('GET', path, secure=secure, **{
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 473, in generic
    return self.request(**r)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 719, in request
    self.check_exception(response)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 580, in check_exception
    raise exc_value
  File "/usr/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/oauth2/views.py", line 77, in view
    return self.dispatch(request, *args, **kwargs)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/oauth2/views.py", line 134, in dispatch
    token = self.adapter.parse_token(access_token)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/views.py", line 92, in parse_token
    identity_data = self.get_verified_identity_data(data["id_token"])
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/views.py", line 67, in get_verified_identity_data
    identity_data = jwt.decode(
TypeError: decode() got an unexpected keyword argument 'verify'

======================================================================
ERROR: test_login (allauth.socialaccount.providers.apple.tests.AppleTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/django/test/utils.py", line 387, in inner
    return func(*args, **kwargs)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/tests.py", line 167, in test_login
    resp = self.login(
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/tests.py", line 210, in login
    resp = self.client.get(resp.url)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 742, in get
    response = super().get(path, data=data, secure=secure, **extra)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 396, in get
    return self.generic('GET', path, secure=secure, **{
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 473, in generic
    return self.request(**r)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 719, in request
    self.check_exception(response)
  File "/usr/lib/python3.9/site-packages/django/test/client.py", line 580, in check_exception
    raise exc_value
  File "/usr/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/oauth2/views.py", line 77, in view
    return self.dispatch(request, *args, **kwargs)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/oauth2/views.py", line 134, in dispatch
    token = self.adapter.parse_token(access_token)
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/views.py", line 92, in parse_token
    identity_data = self.get_verified_identity_data(data["id_token"])
  File "/build/python-django-allauth/src/python-django-allauth-0.46.0/allauth/socialaccount/providers/apple/views.py", line 67, in get_verified_identity_data
    identity_data = jwt.decode(
TypeError: decode() got an unexpected keyword argument 'verify'

----------------------------------------------------------------------
Ran 593 tests in 8.129s

FAILED (errors=2, expected failures=2)
Destroying test database for alias 'default'...
test_account_refresh_token_saved_next_login (allauth.socialaccount.providers.edx.tests.EdxTests)
test_account_refresh_token_saved_next_login (allauth.socialaccount.providers.edx.tests.EdxTests)
test_account_tokens (allauth.socialaccount.providers.edx.tests.EdxTests)
test_login (allauth.socialaccount.providers.edx.tests.EdxTests)
```

On Arch Linux we currently have:

* pyjwt 2.2.0
* requests 2.26.0
* requests-oauthlib 1.3.0
* openid 3.2.0
* django 3.2.9


Discussion:
It seems that with newer pyjwt versions `jwt.decode()` does not need to be called with `verify=True` anymore (it defaults to having an unset `options` parameter, which default to defining `verify_signature=True`).


Upon further investigation, the `verify` parameter has been deprecated with pyjwt 1.7.1 and it is safe to remove it.
I will open a pull request for it.

Resolving patch:
diff --git a/allauth/socialaccount/providers/apple/views.py b/allauth/socialaccount/providers/apple/views.py
--- a/allauth/socialaccount/providers/apple/views.py
+++ b/allauth/socialaccount/providers/apple/views.py
@@ -68,7 +68,6 @@ def get_verified_identity_data(self, id_token):
                 id_token,
                 public_key,
                 algorithms=["RS256"],
-                verify=True,
                 audience=allowed_auds,
                 issuer="https://appleid.apple.com",
             )


Test patch: