Comments (48)
im also getting same issue
from social_media_app.
I am getting the same issue too, cant connect with appwrite
from social_media_app.
When the code in the file config.ts executes this line
const currentAccount = await account.get()
it does not connect to Appwrite, in the console shows this:Does anyone have the same issue?
did you get the issue resolved?
from social_media_app.
Yes, I ran into this issue.
I solved it by starting a (1) "web" client, and (2) changing hostname to
*
Can step by step run through what you did for it to work?
from social_media_app.
@IasmimCristina , Can u please try replacing the
appwriteConfig.databaseId and appwriteConfig.useCollectionId
with the values of those in quotes
Hello!
I have done that, actually, my code was like that but I changed it when I made that screenshot.
(And it was with the double quotes π’)
The difference it makes is that when the sign in page loads it doesn't get the unauthorized error message.
However, when I reload the page the session doesn't persist still and when I logout I get the unauthorized error message again.
from social_media_app.
@IasmimCristina , Can u please try replacing the
appwriteConfig.databaseId and appwriteConfig.useCollectionId
with the values of those in quotesHello!
I have done that, actually, my code was like that but I changed it when I made that screenshot.
(And it was with the double quotes π’)The difference it makes is that when the sign in page loads it doesn't get the unauthorized error message.
However, when I reload the page the session doesn't persist still and when I logout I get the unauthorized error message again.
Hey @IasmimCristina, If you don't mind, can you please invite me to your project repo, I'll do my best to resolve the issue.
from social_media_app.
"Fantastic @Onunkwor! π I'm glad to hear that you resolved the issue. It's always those little details that can make a big difference. Kudos! Also, great catch on fixing the getCurrentUser functionβconsistent casing is key. If you run into any more challenges or have questions in the future, feel free to reach out. Happy coding! π©βπ»π"
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
hey! were you able to resolve the issue? i have been facing the same problem for a few hours now and have been unable to tackle it
Hey @siya-pathak, Yeah I'm able to resolve it.
hi could you tell me how did you? i did refer to [https://github.com//issues/19#issuecomment-1807460381](this comment here) and the sign-up is working fine now after making this modification, but i just wanted to know any other way this could be solved :)
You can use local storage to save the user ID, so that it won't complain about the 401 as we're using the user id from local storage whenever we make a call to AppWrite. So why we're using local storage here, overtime AppWrite fails to fetch the user id from AppWrite's session, which results in 401. And don't forget to clear the local storage on sign out.
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
hey! were you able to resolve the issue? i have been facing the same problem for a few hours now and have been unable to tackle it
Hey @siya-pathak, Yeah I'm able to resolve it.
hi could you tell me how did you? i did refer to [https://github.com//issues/19#issuecomment-1807460381](this comment here) and the sign-up is working fine now after making this modification, but i just wanted to know any other way this could be solved :)
You can use local storage to save the user ID, so that it won't complain about the 401 as we're using the user id from local storage whenever we make a call to AppWrite. So why we're using local storage here, overtime AppWrite fails to fetch the user id from AppWrite's session, which results in 401. And don't forget to clear the local storage on sign out.
thank you so much for this :)
from social_media_app.
Yes, I ran into this issue.
I solved it by starting a
(1) "web" client, and
(2) changing hostname to *
from social_media_app.
I tried that but still is not working, I also tried to delete the project and create a new one but still is giving me the same error
from social_media_app.
I tried that but still is not working, I also tried to delete the project and create a new one but still is giving me the same error
If your code is 100% correct, it has to be appwrite.
Make sure you set up your auth and database correctly. That's the best advice I can give without looking at your code.
from social_media_app.
I tried that but still is not working, I also tried to delete the project and create a new one but still is giving me the same error
Sorry I haven't had time to write a proper response, but @Rondev9 created it here. These are the steps you must take: #3 (comment)
from social_media_app.
Sorry I haven't had time to write a proper response, but @Rondev9 created it here. These are the steps you must take: #3 (comment)
from social_media_app.
I tried that but still is not working, I also tried to delete the project and create a new one but still is giving me the same error
Sorry I haven't had time to write a proper response, but @Rondev9 created it here. These are the steps you must take: #3 (comment)
from social_media_app.
I am dealing with the same issue and creating a web platform did not fix it.
from social_media_app.
When the code in the file config.ts executes this line
const currentAccount = await account.get()
it does not connect to Appwrite, in the console shows this:
Does anyone have the same issue?did you get the issue resolved?
No, I search for different solutions but I still can't figure it out
from social_media_app.
When the code in the file config.ts executes this line
const currentAccount = await account.get()
it does not connect to Appwrite, in the console shows this:
Does anyone have the same issue?did you get the issue resolved?
No, I search for different solutions but I still can't figure it out
Hey @ludwing979 in order to tackle with the 401, I'm using local storage to store the userId (as a bruteforce method) and on sign out I'm clearing the local storage to delete the current user session.
Here's the reference:
Sign-in:
export async function signInAccount(user: { email: string; password: string }) {
try {
const session = await account.createEmailSession(user.email, user.password);
localStorage.setItem("sessionId", session.userId); //userId stored as a sessionId -> purpose of storing is after some time of user log in, when try to fetch useId on reload the appWrite is unable to fetch resulting 401
return session;
} catch (error) {
console.log(error);
}
}
Sign-out:
export async function signOutAccount() {
try {
localStorage.clear();
const session = await account.deleteSession("current");
return session;
} catch (error) {
console.log(error);
}
}
Hope it helps π
from social_media_app.
When the code in the file config.ts executes this line
const currentAccount = await account.get()
it does not connect to Appwrite, in the console shows this:
Does anyone have the same issue?did you get the issue resolved?
No, I search for different solutions but I still can't figure it out
Hey @ludwing979 in order to tackle with the 401, I'm using local storage to store the userId (as a bruteforce method) and on sign out I'm clearing the local storage to delete the current user session. Here's the reference:
Sign-in:
export async function signInAccount(user: { email: string; password: string }) { try { const session = await account.createEmailSession(user.email, user.password); localStorage.setItem("sessionId", session.userId); //userId stored as a sessionId -> purpose of storing is after some time of user log in, when try to fetch useId on reload the appWrite is unable to fetch resulting 401 return session; } catch (error) { console.log(error); } }
Sign-out:
export async function signOutAccount() { try { localStorage.clear(); const session = await account.deleteSession("current"); return session; } catch (error) { console.log(error); } }
Hope it helps π
I tried that but the issue remains, the problem as shown in the screenshot seems to be at the getCurrentUser.
from social_media_app.
Hey @athskouroliakos, If it's acceptable to you, kindly add me to your repository. This will allow me to thoroughly study the code, and I assure you that I will contribute towards resolving the error.
from social_media_app.
@Rondev9 Can I also add you to my repository to check, I have the same problem as @athskouroliakos
from social_media_app.
@Rondev9 Can I also add you to my repository to check, I have the same problem as @athskouroliakos
Sure @ludwing979! Please go ahead.
from social_media_app.
Were you able to fix it? @athskouroliakos @Rondev9 , I'm facing the same issue.
from social_media_app.
Were you able to fix it? @athskouroliakos @Rondev9 , I'm facing the same issue.
@IasmimCristina, can you pls share the screenshots if you don't mind
from social_media_app.
Here they are:
Im basically receiving the same error as the author of the issue, I've already added the Web platform, and re-made the project in appwrite and checked JSM's code. Weirdly, yesterday it was working fine, but now when I re-load the page the session doesnt work.
The local storage message appears once I login and the first ones as soon as the app loads the signin page.
Here are the functions and console ninja error messages, the same mentioned:
The unathourized error is refering to this line:
const currentAccount = await account.get();
from social_media_app.
@IasmimCristina , Can u please try replacing the
appwriteConfig.databaseId and appwriteConfig.useCollectionId
with the values of those in quotes
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
from social_media_app.
I'm having a 401 authorization issue when I try to sign up or sign in. The users are correctly added to app write and the local storage but the page doesn't redirect and I have these issues @Rondev9
![Screenshot 2023-12-06 225449](https://private-user-images.githubusercontent.com/126721072/288563402-dff12882-7f5f-43ed-b8f8-cecb2059ef1a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM4ODQ0NzIsIm5iZiI6MTcyMzg4NDE3MiwicGF0aCI6Ii8xMjY3MjEwNzIvMjg4NTYzNDAyLWRmZjEyODgyLTdmNWYtNDNlZC1iOGY4LWNlY2IyMDU5ZWYxYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxN1QwODQyNTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jMzczOGE5OWY5YmQxMTFkNDFiYTYwYzU2YWM2Yzg4OTM3NDcxNTJmNzExZWFkZTZjOGRmYmJiMzAxY2Y2ODFmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.eV0fWvG1BedmVnAxSgMZP5Au38S-BN_5edVTEGs6jH8)
from social_media_app.
I'm having a 401 authorization issue when I try to sign up or sign in. The users are correctly added to app write and the local storage but the page doesn't redirect and I have these issues @Rondev9
![]()
Hey @Onunkwor, invite me to your project, So that I can understand more about the issue.
from social_media_app.
@Rondev9 Good morning I've done that
from social_media_app.
Thank you @Rondev9 I found a solution to it. I added permission to the saveToDb function which worked. I also faced an invalid query error in the getCurrentUser function cos I used [Query.equal("accountId", currentAccount.$id)] instead of [Query.equal("accountID", currentAccount.$id)] because when saving the user to the database I used accountID
from social_media_app.
@Onunkwor @Rondev9
I updated the code but still getting same error
can you help me to fix this
from social_media_app.
@sridhar-pro Good morning, Are you using .env or .env.local for your API keys?
from social_media_app.
@Onunkwor i'am using .env.local for the API keys
from social_media_app.
@sridhar-pro Sorry about the late reply; I've been caught up with schoolwork. I encountered an error where the API keys were not accessed properly when I used .env.local, so I switched to just .env, and it worked fine.
from social_media_app.
@Onunkwor thank you brother it's worked
from social_media_app.
@sridhar-pro you're welcome
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
hey! were you able to resolve the issue? i have been facing the same problem for a few hours now and have been unable to tackle it
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
hey! were you able to resolve the issue? i have been facing the same problem for a few hours now and have been unable to tackle it
Hey @siya-pathak, Yeah I'm able to resolve it.
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
hey! were you able to resolve the issue? i have been facing the same problem for a few hours now and have been unable to tackle it
Hey @siya-pathak, Yeah I'm able to resolve it.
hi could you tell me how did you? i did refer to [https://github.com//issues/19#issuecomment-1807460381](this comment here) and the sign-up is working fine now after making this modification, but i just wanted to know any other way this could be solved :)
from social_media_app.
@Rondev9 , thank you very much, I invited you just now.
hey! were you able to resolve the issue? i have been facing the same problem for a few hours now and have been unable to tackle it
Hey @siya-pathak, Yeah I'm able to resolve it.
hi could you tell me how did you? i did refer to [https://github.com//issues/19#issuecomment-1807460381](this comment here) and the sign-up is working fine now after making this modification, but i just wanted to know any other way this could be solved :)
You can use local storage to save the user ID, so that it won't complain about the 401 as we're using the user id from local storage whenever we make a call to AppWrite. So why we're using local storage here, overtime AppWrite fails to fetch the user id from AppWrite's session, which results in 401. And don't forget to clear the local storage on sign out.
thank you so much for this :)
You're welcome @siya-pathak. Happy coding ππ
from social_media_app.
When i am creating a new user, even it gets stored in my DB of appwrite, then still it can't get updated in my redux store, the login and logout is working fine only the Signup is creating problem
Please help me anybody
my userdetails slice looks like this
export const userDetails = createAsyncThunk('userDetails', async () => {
try {
const getData = await account.get()
return getData;
} catch (error) {
return 0
}
})
worked fine with login and logout just problem with the Signup
Sign up function :
e.preventDefault()
const promise = account.create(
uuidv4(),
user.email,
user.password,
user.name
);
promise.then(
function (response) {
console.log(response);
if (response) {
dispatch(userDetails()); // Dispatch userDetails action to update the Redux state
}
navigate("/") //Success
},
function (error) {
console.log(error); //Failed
}
)
}
please help meeee
from social_media_app.
I faced the same issue, it is because account.get() will not return the current account immediately, which throws the execution to the catch block. And hence you are receiving this error.
To solve this error, I created a separate function to get the current user using the account.get function and then call it inside the getCurrentUser function ( if that is what you have named it )
export async function getAccount() {
try {
const currentAccount = await account.get();
return currentAccount;
} catch (error) {
console.log(error);
}
}
then use this getAccount function to fetch your user account details in your main function.
from social_media_app.
I faced the same issue, it is because account.get() will not return the current account immediately, which throws the execution to the catch block. And hence you are receiving this error.
To solve this error, I created a separate function to get the current user using the account.get function and then call it inside the getCurrentUser function ( if that is what you have named it )
export async function getAccount() { try { const currentAccount = await account.get(); return currentAccount; } catch (error) { console.log(error); } }
then use this getAccount function to fetch your user account details in your main function.
But bro as you can see in my starting line of response the code is same as like yours, I used the async await to get user in seperate function :(
from social_media_app.
I faced the same issue, it is because account.get() will not return the current account immediately, which throws the execution to the catch block. And hence you are receiving this error.
To solve this error, I created a separate function to get the current user using the account.get function and then call it inside the getCurrentUser function ( if that is what you have named it )
export async function getAccount() { try { const currentAccount = await account.get(); return currentAccount; } catch (error) { console.log(error); } }
then use this getAccount function to fetch your user account details in your main function.
But bro as you can see in my starting line of response the code is same as like yours, I used the async await to get user in seperate function :(
Can you try to call the account.create() function seperately and call it again by returning from another function and try. If this doesn't work, let's connect and debug this together
from social_media_app.
I debugged it a little bit further. Actually this error makes complete sense. And it is not a bug like it was mentioned in the video.
It behaves like intended. You are not logged in so you go to sign-in. As soon as you comment out cookieFallback === null, the method checkAuthUser() is called, but since you are guest (not a logged In user) you do not have an account. So this error occurs.
How this is setup up you will never see the sign-up page.
Now change the line in useEffect to /sign-up.
After you sign-up you will automatically logged In and after you will not get that error any longer.
I did not through with the video, So I do not know how the pageflow will be. But I think that you need some expections while checking the user. If you are not logged In I would redirect you to sign-up. If you click on sign-in you need a further check in useEffect, to ensure that the user stays on sign-in without gettting redirected to sign-up again.
And then you are done ;-)
from social_media_app.
Ok, I have managed it to work correctly with an easy fix:
`const [isAuthenticated, setIsAuthenticated] = useState(false)
const navigate = useNavigate()
const location = useLocation()
const checkAuthUser = async () => {
setIsLoading(true)
try {
`
Add const location = userLocation()
and use it in the useEffect Method
` useEffect(() => {
const cookieFallback = localStorage.getItem("cookieFallback");
if (
cookieFallback === "[]" ||
cookieFallback === null ||
cookieFallback === undefined
) {
if (location.pathname === "/sign-in") {
navigate("/sign-in");
} else {
navigate("/sign-up");
}
}
checkAuthUser();
}, []);
`
Now the app is working as expected without the 401 Unauthorized User guest as not account exception
from social_media_app.
@Rondev9 Please help me I am struggling with he issue
from social_media_app.
Related Issues (20)
- An error in useGetPosts in queries.ts HOT 11
- A warning in Explore.tsx... HOT 1
- A warning in api.ts... HOT 1
- The error states "Access to XMLHttpRequest at 'https://cloud.appwrite.io/v1/account' from origin 'http://localhost:5173/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." HOT 2
- An error regarding imageUrl in api.ts file
- Copied repo, followed all the steps. Get errors HOT 2
- What's with the type error in Explore? HOT 3
- Local host issue HOT 1
- type error in PostStats.tsx (solution)
- not able to process the user id
- vite-plugin error on globals.css file HOT 1
- anyone, who has completed the feature which are not explained in the video please send me a DM. HOT 3
- Getting this Ugly Sign Up Screen HOT 1
- Deployment error || Everything ok in localhost
- EMPTY ACCOUNT?? HOT 1
- TypeError: Cannot read properties of undefined (reading 'replace') HOT 1
- SignIn Error HOT 1
- Unable to Sign Up and Log In after Deployment on Vercel
- Image not loading on browser.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from social_media_app.