docs: def oauth_connect(self, provider, action):
          """
          This endpoint doesn't check if user is logged in, because it has two functions
  
          1. If the user is not logged in, it will try to signup the user
              - if the social info exist, it will login
              - not, it will create a new account and proceed
          2. If user is logged in, it will try to create a social login entry with
              the current user
  
          **** This methods doesn't save the user token, it only retrieves the ID
                to login or ID, name, email if signing up
  
          :param provider:
          :param action: connect|authorized|
              - connect: to connect to the endpoint
              - authorized, when coming back
          """
          valid_actions = ["connect", "authorized", "test"]
  
          _redirect = views.auth.Account.account_settings if is_authenticated() else self.login
  
          if action not in valid_actions \
                  or "oauth" not in __options__.get("registration_methods") \
                  or not __options__.get("allow_registration") \
                  or not hasattr(oauth, provider):
              return redirect(_redirect)
  
          client = getattr(oauth, provider)
          params = client.__params__
          me_args = params.get("me")
          user_id = params.get("user_id")
          oauth_user_id = None
          oauth_name = None
          oauth_email = None
  
          if action == "test":
              session_data = {
                  "provider": "ensure",
                  "user_id": "1234",
                  "name": "Mardix",
                  "email": "mardix@email.com",
              }
              set_oauth_session(session_data)
              return redirect(url_for(self.register, oauth=1))
  
          if action == "connect":
              _next = request.args.get('next')
              authorized_url = url_for(self,
                                       provider=provider,
                                       action="authorized",
                                       next=_next or request.referrer or None,
                                       _external=True)
              return client.authorize(callback=authorized_url)
          elif action == "authorized":
              resp = client.authorized_response()
              if resp is None:
                  pass
              elif isinstance(resp, OAuthException):
                  flash_error("Access Denied")
              else:
                  if not me_args:
                      oauth_user_id = resp.get(user_id)
                  else:
                      me = client.get(me_args)
  
          if action == "authorized" and oauth_user_id:
              if is_authenticated():
                  try:
                      # Add federated login to current_user
                      current_user.add_federated_login(provider=provider,
                                                    federated_id=oauth_user_id)
                      flash_success(
                          "You can now login with your %s account" % provider.upper())
                  except Exception as e:
                      logging.exception(e)
                  return redirect(views.auth.Account.account_settings)
  
              # User not logged in
              else:
                  # Existing user
                  user = with_federation(provider, oauth_user_id)
                  if user:
                      create_session(user)
                      return redirect(request.args.get("next") or __options__.get(
                          "login_view"))
  
                  # New User
                  else:
                      session_data = {
                          "provider": provider,
                          "user_id": oauth_user_id,
                          "name": oauth_name,
                          "email": oauth_email,
                      }
                      set_oauth_session(session_data)
  
          else:
              return redirect(_redirect)
  
          return {
              "action": action,
              "provider": provider,
              "authorized_url": ""
  
          }
  
          return redirect(_redirect)