Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

up #1793

Merged
merged 3 commits into from
Jan 10, 2025
Merged

up #1793

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "r2r-js",
"version": "0.4.12",
"version": "0.4.13",
"description": "",
"main": "dist/index.js",
"browser": "dist/index.browser.js",
Expand Down
20 changes: 20 additions & 0 deletions js/sdk/src/v3/clients/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,4 +539,24 @@ export class UsersClient {
async oauthGithubAuthorize(): Promise<{ redirect_url: string }> {
return this.client.makeRequest("GET", "users/oauth/github/authorize");
}

@feature("users.oauthGoogleCallback")
async oauthGoogleCallback(options: { code: string; state: string }): Promise<any> {
return this.client.makeRequest("POST", "users/oauth/google/callback", {
params: {
code: options.code,
state: options.state,
},
});
}

@feature("users.oauthGithubCallback")
async oauthGithubCallback(options: { code: string; state: string }): Promise<any> {
return this.client.makeRequest("POST", "users/oauth/github/callback", {
params: {
code: options.code,
state: options.state,
},
});
}
}
4 changes: 2 additions & 2 deletions py/core/main/api/v3/retrieval_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ async def stream_generator():
return

return StreamingResponse(
stream_generator(), media_type="application/json"
stream_generator(), media_type="text/event-stream"
) # type: ignore
else:
return response
Expand Down Expand Up @@ -673,7 +673,7 @@ async def stream_generator():
return

return StreamingResponse(
stream_generator(), media_type="application/json"
stream_generator(), media_type="text/event-stream"
) # type: ignore
else:
return response
Expand Down
8 changes: 4 additions & 4 deletions py/core/main/api/v3/users_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def validate_password(password: str) -> bool:

# if not validate_password(password):
# raise R2RException(
# status_code=400,
# message=f"Password must be at least 10 characters long and contain at least one uppercase letter, one lowercase letter, one digit, and one special character from '!@#$%^&*'.",
# f"Password must be at least 10 characters long and contain at least one uppercase letter, one lowercase letter, one digit, and one special character from '!@#$%^&*'.",
# 400,
# )

registration_response = await self.services.auth.register(
Expand Down Expand Up @@ -1790,7 +1790,7 @@ async def google_authorize():

@self.router.get("/users/oauth/google/callback")
async def google_callback(
request: Request, code: str = Query(...), state: str = Query(...)
code: str = Query(...), state: str = Query(...)
):
"""
Google's callback that will receive the `code` and `state`.
Expand All @@ -1807,7 +1807,6 @@ async def google_callback(
"grant_type": "authorization_code",
},
).json()

if "error" in token_data:
raise HTTPException(
status_code=400,
Expand Down Expand Up @@ -1839,6 +1838,7 @@ async def google_callback(
oauth_id=google_id,
email=email,
)
print("token_response = ", token_response)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the print statement or replace it with proper logging for production code.


# 4. Return tokens or redirect to your front-end
# Some people store tokens in a cookie or redirect to a front-end route passing them as a query param.
Expand Down
Loading
Loading