deno_kv_oauth + hono how to fetch data from google profile: state, plans, method names changing.
In code examples i found in internet, used methods which already not the part of deno_kv_oauth.
1. Is there examples how to manage data for case of google(actually i plan to implement use facebook for authentication too)?
2. Will the future versions of deno_kv_oauth have changes in method names and structure of the lib?
Feel free to mention me. In advance thank you for your time.
The attached code in file is my attempt to get data from google. At the moment it does not work.
Here is shorten version.
10 Replies
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the code snippet you've provided, I can offer some general advice, but please note that this advice is not based on the Deno documentation, and I advise you to double-check the accuracy of the advice given.
Looking at your code, there are a few things that stand out:
1. You are attempting to store tokens in a global variable
g_tokens
. This approach is not recommended for production code because it can lead to race conditions and is not safe if your server is handling multiple requests concurrently. Instead, consider using a more robust session management or state management solution.
2. The getSessionId
and handleCallback
functions are not defined in your snippet. Make sure these functions are properly implemented and imported if they are part of a separate module.
3. The Context
type should be imported from Hono if it's not already in scope. Ensure that you have the correct imports at the top of your file.
4. The Tokens
type for g_tokens
is not defined in your snippet. Ensure that you have defined this type or imported it if it's part of a library.
5. The Deno.serve(app.fetch)
line at the end seems to be missing the options argument. It should be something like Deno.serve({ handler: app.fetch })
.
6. The RedirectStatusCode
type is not defined in your snippet. If it's a custom type, make sure it's properly imported or defined.
Regarding your questions:
1. For examples on how to manage data for Google or Facebook authentication, you would typically look for up-to-date examples or tutorials that use the latest version of the libraries you're working with. Since I cannot provide you with specific examples, I recommend searching for recentarticles or official library documentation.
2. As for future versions of
deno_kv_oauth
and potential changes in method names and structure, this information would typically be found in the library's changelog, release notes, or by following the library's development on its repository. Library authors may deprecate methods and introduce breaking changes with major version updates, so it's important to keep an eye on the library's development and update your code accordingly.
Remember to always refer to the latest official documentation and resources for the most accurate and up-to-date information.please no AI answers anymore. If i would like communicate with crapper, i can use chatgpt, perplexity, phindcom etc. And i would like avoid the answers from tool which does not understand that code shortened, so of course imports were cut.
Have you set up these env vars:
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
?
i will set them up, using flags(deno deploy) or .env file(for dev), the question is how to get properly .profile data using deno lib, since getGithub(Google)User methods were removed from lib.
// !!! how to get google user name or login from .profile using oauth2 deno library methods?
so it is not a question about error or when something not works as expected. it is question about correct way to do desirable actions using deno lib, without "reinventing bicycle" @Leokuma
That's beyond my knowledge 😔
i have tiny step forward. it is wip , but the process is alive. In the examples from docs, almost everything is deprecated or wrong (i use typescript)
handleCallback()
resolves to an object that contains the OAuth access token. Use the access token to make a request to the Google REST API for the user's name.
Can you please clarify what this means?in short words. At the moment i not fully understand the code flow in google oauth2 staff implementation, but it works partially(probably code is dirty).
In same time , i would like to have good example how to implement (not only code but code design too... files folders etc) , the double login functionality using oauth2 deno + hono, for google and facebook(to have vision how to implement multilogin based on these two properly).
that it has:
- signin, signout, request data(user name etc) from google oauth2 api
- signin, signout, request data(user name etc) from facebook oauth2 api
- good file structure of the project, not the pile of code in one place
so i am in process, at the moment it looks like this
https://github.com/healingdrawing/play-deno-kv-oauth
and i alredy see not clear place, because some providers requires "/callback" for oauth callback so i cant just use app.get("/callback_google") etc to easily separete the flow. can not find this info at the moment, probably i could be wrong
GitHub
GitHub - healingdrawing/play-deno-kv-oauth
Contribute to healingdrawing/play-deno-kv-oauth development by creating an account on GitHub.
wth. facking facebook requirements, to just implement oauth2 login, you need pass 100500 checks and confirm business(even if you said you are a student , and named app as "test"). Naziberg
at the moment at least twitter and google alive. Facebook looks not user(developer) friendly