MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / save_token

Method save_token

env_manager.py:106–121  ·  view source on GitHub ↗

Saves the token to the .env file. This will create or overwrite the file.

(self, token)

Source from the content-addressed store, hash-verified

104 return None
105
106 def save_token(self, token):
107 """
108 Saves the token to the .env file. This will create or overwrite the file.
109 """
110 try:
111 with open(self.env_file_path, 'w') as f:
112 f.write(f'RAGNAR_OPENAI_API_KEY={token}\n')
113
114 # Also set it in the current running process's environment for immediate use
115 os.environ['RAGNAR_OPENAI_API_KEY'] = token
116
117 logger.info(f"Token saved to {self.env_file_path}")
118 return {"success": True, "message": "✓ API token saved. Please restart the Ragnar service to apply the changes."}
119 except Exception as e:
120 logger.error(f"Failed to save token to .env file: {e}", exc_info=True)
121 return {"success": False, "message": f"✗ Failed to save token to .env file: {e}"}
122
123 def get_token_status(self):
124 """

Callers 1

save_ai_tokenFunction · 0.95

Calls 3

infoMethod · 0.80
errorMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected