Debian Codegraph @

allauth/socialaccount/providers/evernote/views.py

raw
1 from __future__ import annotations
2
3 from datetime import datetime
4
5 from django.http import HttpRequest
6
7 from allauth.socialaccount import app_settings
8 from allauth.socialaccount.providers.oauth.views import (
9 OAuthAdapter,
10 OAuthCallbackView,
11 OAuthLoginView,
12 )
13
14
15 class EvernoteOAuthAdapter(OAuthAdapter):
16 provider_id = "evernote"
17 settings = app_settings.PROVIDERS.get(provider_id, {})
18 _hostname = settings.get("EVERNOTE_HOSTNAME", "sandbox.evernote.com")
19 request_token_url = f"https://{_hostname}/oauth"
20 access_token_url = f"https://{_hostname}/oauth"
21 authorize_url = f"https://{_hostname}/OAuth.action"
22 del _hostname
23
24 def complete_login(self, request: HttpRequest, app, token, **kwargs):
25 response = kwargs["response"]
26 token.expires_at = datetime.fromtimestamp(
27 int(response["edam_expires"]) / 1000.0
28 )
29 extra_data = response
30 return self.get_provider().sociallogin_from_response(request, extra_data)
31
32
33 oauth_login = OAuthLoginView.adapter_view(EvernoteOAuthAdapter)
34 oauth_callback = OAuthCallbackView.adapter_view(EvernoteOAuthAdapter)