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

feat: Add Google Oauth Token Component #4383

Merged

Conversation

viniciossilva3
Copy link
Contributor

  • Added the Google JSON Token component, which generates tokens for using Google APIs via OAuth.
  • The component was mentioned in the Documentation but does not yet exist in the main repository: docs: add google integration #4382

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Nov 4, 2024
Copy link
Contributor

@ogabrielluiz ogabrielluiz left a comment

Choose a reason for hiding this comment

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

Hey @viniciossilva3

This is nice. What are some use cases we can add to this?

Also, have you seen the LinkInput? Could be useful if you want to show a link dynamically

@viniciossilva3
Copy link
Contributor Author

Hey @viniciossilva3

This is nice. What are some use cases we can add to this?

Also, have you seen the LinkInput? Could be useful if you want to show a link dynamically

Hi @ogabrielluiz,

1 - To use certain Google applications that require OAuth permissions (Drive, Sheets, Docs, Gmail and others...), you'll need a JSON string containing user data and an authentication token. For the existing components in Langflow (Google Drive Search, Google Drive Loader, and Gmail Loader), I found that the only way to access them was via the token generated by this component.

2 - Thanks, I didn't know, I'll check the use of LinkInput to add to the component.

Copy link

codspeed-hq bot commented Nov 5, 2024

CodSpeed Performance Report

Merging #4383 will degrade performances by 22.54%

Comparing viniciossilva3:feat-google-oauth-component (8594413) with main (69a1c16)

Summary

❌ 1 regressions
✅ 14 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main viniciossilva3:feat-google-oauth-component Change
test_invalid_run_with_input_type_chat 13.6 ms 17.5 ms -22.54%

@ogabrielluiz ogabrielluiz added the lgtm This PR has been approved by a maintainer label Nov 5, 2024
@ogabrielluiz
Copy link
Contributor

Hey @viniciossilva3

There are many lint and formatting errors that you still need to fix for us to approve this PR.

@viniciossilva3
Copy link
Contributor Author

Hey @viniciossilva3

There are many lint and formatting errors that you still need to fix for us to approve this PR.

I'll fix it now, I saw that autofix removed the import.

@ogabrielluiz
Copy link
Contributor

Try running make format and make lint to check the issues.

@viniciossilva3
Copy link
Contributor Author

Try running make format and make lint to check the issues.

Thanks for the tip, thanks to that I was able to solve the problems. Can you check if everything is correct?

flow = InstalledAppFlow.from_client_secrets_file(client_secret_file, scopes)
creds = flow.run_local_server(port=0)

with token_path.open(mode="w", encoding="utf-8") as token_file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: use Path.write_text()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @cbornet , thank you!
I think it got better with your tip.

@ogabrielluiz ogabrielluiz enabled auto-merge (squash) November 11, 2024 01:41
viniciossilva3 and others added 12 commits November 10, 2024 22:42
- Added documentation teaching how to configure an application using Google's OAuth API to use the components present in Langflow. Example: (Google Drive Loader, Google Drive Search and Gmail Loader).

Co-authored-by: Vinícios Batista da Silva <[email protected]>
- Added the Google JSON Token component, which generates tokens for using Google APIs via OAuth.
- The component was mentioned in the Documentation but does not yet exist in the main repository: langflow-ai#4382

Co-authored-by: Vinícios Batista da Silva <[email protected]>
Thanks, I've already made the correction. I'll be more careful.

Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
- Removed unnecessary comments.
- Refactored the return of the component's build function to make the code easier to read and to facilitate the correct return of output data.
- Removed a space in the string of the component's display name
- StrInput has been replaced by MultilineInput to provide more workspace for the user to add scope URLs.

Co-authored-by: Vinícios Batista da Silva <[email protected]>
- Fixed Lint issue in file, json import added.
- Removed values ​​with populated scope urls.

Co-authored-by: Vinícios Batista da Silva <[email protected]>
- Lint issues fixed
- Refactored the use of paths in the component to avoid lint issues in "token.json"

Co-authored-by: Vinícios Batista da Silva <[email protected]>
- Simplifies file handling by removing manual open/close steps

Co-authored-by: Vinícios Batista da Silva <[email protected]>
@ogabrielluiz ogabrielluiz merged commit fa28541 into langflow-ai:main Nov 11, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants