@must_be_logged_in
def dataverse_add_user_account(auth, **kwargs):
 user = auth.user
 provider = DataverseProvider()
 host = request.json.get('host').rstrip('/')
 api_token = request.json.get('api_token')
 client.connect_or_error(host, api_token)
 try:
  provider.account = ExternalAccount(provider=provider.short_name, provider_name=provider.name, display_name=host, oauth_key=host, oauth_secret=api_token, provider_id=api_token)
  provider.account.save()
 except ValidationError:
  provider.account = ExternalAccount.objects.get(provider=provider.short_name, provider_id=api_token)
 if (not user.external_accounts.filter(id=provider.account.id).exists()):
  user.external_accounts.add(provider.account)
 user_addon = auth.user.get_addon('dataverse')
 if (not user_addon):
  user.add_addon('dataverse')
 user.save()
 user.get_or_add_addon('dataverse', auth=auth)
 user.save()
 return {}

@ must_be_logged_in def dataverse_add_user_account ( auth , ** kwargs ) : user = auth . user provider = DataverseProvider ( ) host = request . json . get ( 'host' ) . rstrip ( '/' ) api_token = request . json . get ( 'api_token' ) client . connect_or_error ( host , api_token ) try : provider . account = ExternalAccount ( provider = provider . short_name , provider_name = provider . name , display_name = host , oauth_key = host , oauth_secret = api_token , provider_id = api_token ) provider . account . save ( ) except ValidationError : provider . account = ExternalAccount . objects . get ( provider = provider . short_name , provider_id = api_token ) if ( not user . external_accounts . filter ( id = provider . account . id ) . exists ( ) ) : user . external_accounts . add ( provider . account ) user_addon = auth . user . get_addon ( 'dataverse' ) if ( not user_addon ) : user . add_addon ( 'dataverse' ) user . save ( ) user . get_or_add_addon ( 'dataverse' , auth = auth ) user . save ( ) return { }
verifies new external account credentials and adds to users list .