<commit_before>"""
Forms to support third-party to first-party OAuth 2.0 access token exchange
"""
<<<<<<< HEAD
import provider.constants
=======
import requests
>>>>>>> authenticate to linkedin mobile in login
from django.contrib.auth.models import User
from django.forms import CharField, BooleanField
from edx_oauth2_provider.constants import SCOPE_NAMES
from oauth2_provider.models import Application
from provider.forms import OAuthForm, OAuthValidationError
from provider.oauth2.forms import ScopeChoiceField, ScopeMixin
from provider.oauth2.models import Client
from requests import HTTPError
from social_core.backends import oauth as social_oauth
from social_core.exceptions import AuthException

from third_party_auth import pipeline

import logging
log = logging.getLogger("edx.student")


class AccessTokenExchangeForm(ScopeMixin, OAuthForm):
    """Form for access token exchange endpoint"""
    access_token = CharField(required=False)
    scope = ScopeChoiceField(choices=SCOPE_NAMES, required=False)
    client_id = CharField(required=False)
    username = CharField(required=False)
    is_linkedin_mobile = BooleanField(default=False)

    def __init__(self, request, oauth2_adapter, *args, **kwargs):
        super(AccessTokenExchangeForm, self).__init__(*args, **kwargs)
        self.request = request
        self.oauth2_adapter = oauth2_adapter

    def _require_oauth_field(self, field_name):
        """
        Raise an appropriate OAuthValidationError error if the field is missing
        """<commit_msg>dont give default value to BooleanField<commit_after>"""
Forms to support third-party to first-party OAuth 2.0 access token exchange
"""
<<<<<<< HEAD
import provider.constants
=======
import requests
>>>>>>> authenticate to linkedin mobile in login
from django.contrib.auth.models import User
from django.forms import CharField, BooleanField
from edx_oauth2_provider.constants import SCOPE_NAMES
from oauth2_provider.models import Application
from provider.forms import OAuthForm, OAuthValidationError
from provider.oauth2.forms import ScopeChoiceField, ScopeMixin
from provider.oauth2.models import Client
from requests import HTTPError
from social_core.backends import oauth as social_oauth
from social_core.exceptions import AuthException

from third_party_auth import pipeline

import logging
log = logging.getLogger("edx.student")


class AccessTokenExchangeForm(ScopeMixin, OAuthForm):
    """Form for access token exchange endpoint"""
    access_token = CharField(required=False)
    scope = ScopeChoiceField(choices=SCOPE_NAMES, required=False)
    client_id = CharField(required=False)
    username = CharField(required=False)
    is_linkedin_mobile = BooleanField()

    def __init__(self, request, oauth2_adapter, *args, **kwargs):
        super(AccessTokenExchangeForm, self).__init__(*args, **kwargs)
        self.request = request
        self.oauth2_adapter = oauth2_adapter

    def _require_oauth_field(self, field_name):
        """
        Raise an appropriate OAuthValidationError error if the field is missing
        """
{'fraction_non_alphanumeric': 0.07977857375447737, 'fraction_numerical': 0.005861282969716704, 'mean_word_length': 5.2439024390243905, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '245310', 'n_tokens_mistral': 858, 'n_tokens_neox': 843, 'n_words': 249}