Ejemplo n.º 1
0
def api_info(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  if request.method == 'GET':
    return render_to_response('control/api_info.html',
                              {'username' : user.username,
                               'api_key' : user.api_key,
                               'msg' : ""},
                              context_instance=RequestContext(request))

  # This is a POST, so it should be generation of an API key.
  if not request.POST.get('generate_api_key', False):
    msg = "Sorry, we didn't understand your request."
    return profile(request, info, msg) 
    
  interface.regenerate_api_key(user)
  msg = "Your API key has been regenerated. Your old one will no longer work."
  msg += " You should update any places you are using the API key"
  msg += " (e.g. in programs using the XML-RPC client)."
  return profile(request,msg)
Ejemplo n.º 2
0
def api_info(request):
  try:
    user = _validate_and_get_geniuser(request)
  except LoggedInButFailedGetGeniUserError:
    return _show_failed_get_geniuser_page(request)
  
  if request.method == 'GET':
    return render_to_response('control/api_info.html',
                              {'username' : user.username,
                               'api_key' : user.api_key,
                               'msg' : ""},
                              context_instance=RequestContext(request))

  # This is a POST, so it should be generation of an API key.
  if not request.POST.get('generate_api_key', False):
    msg = "Sorry, we didn't understand your request."
    return profile(request, info, msg) 
    
  interface.regenerate_api_key(user)
  msg = "Your API key has been regenerated. Your old one will no longer work."
  msg += " You should update any places you are using the API key"
  msg += " (e.g. in programs using the XML-RPC client)."
  return profile(request,msg)
Ejemplo n.º 3
0
 def regenerate_api_key(pwauth):
   """
   <Purpose>
     Regenerate a user's API key.This requires authenticating with the account
     password rather than the current API key.
   <Arguments>
     pwauth
       An authorization dict that includes a password instead of an apikey.
   <Exceptions>
     None.
   <Returns>
     The new API key.
   """
   geni_user = _pwauth(pwauth)
   return interface.regenerate_api_key(geni_user)
Ejemplo n.º 4
0
 def regenerate_api_key(pwauth):
     """
 <Purpose>
   Regenerate a user's API key.This requires authenticating with the account
   password rather than the current API key.
 <Arguments>
   pwauth
     An authorization dict that includes a password instead of an apikey.
 <Exceptions>
   None.
 <Returns>
   The new API key.
 """
     geni_user = _pwauth(pwauth)
     return interface.regenerate_api_key(geni_user)