MCPcopy
hub / github.com/SciPhi-AI/R2R / login

Method login

py/sdk/sync_methods/users.py:125–160  ·  view source on GitHub ↗

Log in a user. Args: email (str): User's email address password (str): User's password Returns: WrappedLoginResponse

(self, email: str, password: str)

Source from the content-addressed store, hash-verified

123 return WrappedGenericMessageResponse(**response_dict)
124
125 def login(self, email: str, password: str) -> WrappedLoginResponse:
126 """Log in a user.
127
128 Args:
129 email (str): User's email address
130 password (str): User's password
131
132 Returns:
133 WrappedLoginResponse
134 """
135 if self.client.api_key:
136 raise ValueError(
137 "Cannot log in after setting an API key, please unset your R2R_API_KEY variable or call client.set_api_key(None)"
138 )
139 data: dict[str, Any] = {"username": email, "password": password}
140 response_dict = self.client._make_request(
141 "POST",
142 "users/login",
143 data=data,
144 version="v3",
145 )
146
147 login_response = WrappedLoginResponse(**response_dict)
148 self.client.access_token = login_response.results.access_token.token
149 self.client._refresh_token = login_response.results.refresh_token.token
150
151 user = self.client._make_request(
152 "GET",
153 "users/me",
154 version="v3",
155 )
156
157 user_response = WrappedUserResponse(**user)
158 self.client._user_id = user_response.results.id
159
160 return login_response
161
162 def logout(self) -> WrappedGenericMessageResponse | None:
163 """Log out the current user."""

Callers 15

clientFunction · 0.45
login_userMethod · 0.45
clientFunction · 0.45
clientFunction · 0.45
superuser_loginFunction · 0.45
test_user_refresh_tokenFunction · 0.45

Calls 1

_make_requestMethod · 0.45

Tested by 15

clientFunction · 0.36
login_userMethod · 0.36
clientFunction · 0.36
clientFunction · 0.36
superuser_loginFunction · 0.36
test_user_refresh_tokenFunction · 0.36