Merveilleux ce script,
il m'a retourné les infos webdav, j'ai paramétré mon appli de synchro mobile avec les informations retournées, et le login a été validé
j'ai pu me connecter et parcourir mon arborescence
Je ne connais pas - par contre la durée de validité du login/mot de passe cryptés retourné
Mais l'information retournée par ce script est valide; merci !
Pour trace, je colle ici le code du script également
Merci merci merci 🙂
#!/usr/bin/python
# -*- coding: utf-8 -*-
import httplib, urllib
class config:
ovh_host = "ws.ovh.com"
def get_webdav_info(login, password):
ws_info={}
null = None
# Log into CloudNAS with nasLogin and retrieve a session ID
print 'Logging into CloudNAS to retrieve a session ID...'
params = 'session=¶ms={"email":"%s","password":"%s"}' % (urllib.quote(login), urllib.quote(password))
headers = {"Content-type": 'application/x-www-form-urlencoded',
"User-Agent": 'hubiC/0.4.8 beta (Windows NT 6.1; fr_FR)'}
conn = httplib.HTTPSConnection(config.ovh_host)
conn.request("POST", "/cloudnas/r3/ws.dispatcher/nasLogin", params, headers)
resp = conn.getresponse()
s = resp.status
r = resp.reason
data = resp.read()
try:
d = eval(data)
sid = d['answer']['id']
except KeyError:
return ws_info
finally:
conn.close()
print '# SID:', sid
# POST on getNas using session ID to get URL
print 'Retrieving user-specific URL for WebDAV...'
params = 'session=%s' % sid
conn = httplib.HTTPSConnection(config.ovh_host)
conn.request("POST", "/cloudnas/r3/ws.dispatcher/getNas", params, headers)
resp = conn.getresponse()
s = resp.status
r = resp.reason
data = resp.read()
try:
d = eval(data)
ws_info['url'] = d['answer'][0]['url']
except KeyError :
return ws_info
finally:
conn.close()
print '# URL:', ws_info['url']
# POST on getCredentials using session ID to get credentials
print 'Retrieving user-specific credentials for WebDAV...'
params = 'session=%s' % sid
conn = httplib.HTTPSConnection(config.ovh_host)
conn.request("POST", "/cloudnas/r3/ws.dispatcher/getCredentials", params, headers)
resp = conn.getresponse()
s = resp.status
r = resp.reason
data = resp.read()
try:
d = eval(data)
ws_info['login'] = d['answer']['username']
ws_info['passwd'] = d['answer']['secret']
except KeyError:
return ws_info
finally:
conn.close()
print '# Ok'
return ws_info
if __name__ == '__main__':
import sys
import getpass
import os.path
login = raw_input("Login: ")
password = getpass.getpass()
ws_info = get_webdav_info(login, password)
print '''
URL: %(url)s
login: %(login)s
password: %(passwd)s
''' % ws_info