Refresh token์ ์ฅ์ ๋ณธ์ธ์ ์๋ API ์์ฒญ ์ ๋งค๋ฒ Access Token์ ๋ฐ๊ธํ๋ ์์ผ๋ก API๋ฅผ ๊ตฌ์ฑํ์๋๋ฐ, ์ด๋ ๊ฒ ๊ตฌ์ฑํ ๊ฒฝ์ฐ ์ฌ์ฉ์๊ฐ ๋ง์์ง ์๋ก ์์คํ ๋ถํ๊ฐ ์ฆ๊ฐํ๋ค. ๋ฐ๋ผ์ Refresh Token์ ๋ฐ๊ธํ๋ ๊ฒ์ด ๋ซ๋ค. ๋ํ, refresh token์ด ์์ ๊ฒฝ์ฐ access token์ ์ ํจ ์๊ฐ์ ์งง๊ฒ ํ์ฌ ํ์ทจ ์ ๋น ๋ฅด๊ฒ ๋ฌดํจํ ์ํฌ ์ ์๋ค. Refresh token์ ๋์ Access Token์ ํตํด User๊ฐ request๋ฅผ ๋ณด๋ด๊ณ , ์ ํจ ์๊ฐ์ด ๋ง๋ฃ ๋์๋ค๋ ์๋ต์ ๋ฐ๋๋ค. User๋ Access Token๊ณ ํจ๊ป Refresh Token์ ์๋ฒ๋ก ๋ณด๋ธ๋ค. Refresh Token์ด ์ ํจํ๋ค๋ฉด ์ ํจ์๊ฐ์ด ๊ฐฑ์ ๋ Access Token์ด ์๋ก ๋ฐ๊ธ๋์ด User..
token์ cookie์ ์ ์ฅํ ์๋, Web Storage์ ์ ์ฅํ ์๋, Client ์์ฒด์ ์ ์ฅํ ์๋ ์๋ค. Cookie ์ฟ ํค๋ ์๋ฒ๊ฐ ๋ณด๋ธ ๋ฐ์ดํฐ๋ฅผ ์ต๋ 4KB๊น์ง ์ ์ฅ ๊ฐ๋ฅํ๋ค. ํด๋ผ์ด์ธํธ์์ Credential ์์ฑ์ผ๋ก ํ์ฉํ๋ฉด ์๋ฒ์์ ์ ๊ทผ ๊ฐ๋ฅํ๋ค. HTTP Request ์ ์๋์ผ๋ก ํฌํจ๋์ด ์๋ฒ์ ์ฟ ํค ์ ๋ณด๋ฅผ ์ ๊ณต ๊ฐ๋ฅํ๋ค. HttpOnly ์ค์ ์ ์ด์ฉํ์ฌ ์ฌ์ฉ์๊ฐ ์ ์ดํ ์ ์๋๋ก ๋ง๋ค ์ ์๋ค. Web Storage Session Storage ์๋ฒ์์ ์ ๊ทผํ ์ ์๋ค. ์ธ์ ์ด ์ข ๋ฃ๋๋ฉด ๋ชจ๋ ์ญ์ ๋๋ค. 5~10MB์ ํฌ๊ธฐ๋ฅผ ๊ฐ๋๋ค. Local Storage ์๋ฒ์์ ์ ๊ทผํ ์ ์๋ค. ๋ฐ ์๊ตฌ์ ์ผ๋ก ์ ์ฅํ ์ ์๋ค. 5~10MB์ ํฌ๊ธฐ๋ฅผ ๊ฐ๋๋ค. Client Side ํด๋ผ์ด์ธํธ ..
![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FM1Dmd%2FbtrabvwUHnr%2F0rY2gb17EBpX8bk6sgd6p1%2Fimg.png)
๊ฐ๋ ์ ๋ฆฌ ๋ด๊ฐ ์ ๊ณตํ๋ ์๋น์ค๋ฅผ Client, ๋ค๋ฅธ ์๋น์ค๋ฅผ Resource Server, ๋ ์๋น์ค๋ฅผ ๋ชจ๋ ์ด์ฉํ๋ ์ฌ์ฉ์๋ฅผ Resource Owner๋ผ๊ณ ์ ์ํ๋ค. ์ถ๊ฐ์ ์ผ๋ก Resource Server์์ ์ธ์ฆ์ ๋ด๋นํ๋ ์๋ฒ๋ฅผ ๋ฐ๋ก Authorization Server๋ผ๊ณ ํ๋ค. ์ด๋ ๊ฒ ์ฐํฉํด์ ์ธ์ฆ์ฒด๊ณ๋ฅผ ์ ๊ณตํ๋ ๊ฒ์ federated Identity๋ผ๊ณ ๋ถ๋ฅธ๋ค. ๋ฐฐ๊ฒฝ Client๊ฐ Resource Server(google, facebook ๋ฑ)์ ์๋ Resource Owner์ ๊ณ์ ์ ์ ์ํ ์ ์๋ ๋ฐฉ๋ฒ์ ๋ฌด์์ด ์์๊น? Resource Server์ ๋ํ Resource Owner์ id, pw๋ฅผ ์ ๊ณต๋ฐ์ผ๋ฉด ๋ ์ข๊ฒ ์ง๋ง ๋ณด์ ์ ๋ขฐ ๋ฌธ์ ๊ฐ ์๋ค. ๋ฐ๋ผ์ oAuth๊ฐ ๋์๋ค. oAuth๋ฅผ ..
React-query : fetch, cache, synchronize, update(for server state)์ ์ฌ์ฉ๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ด๋ค. ๊ณต์์ฌ์ดํธ React Query Hooks for fetching, caching and updating asynchronous data in React react-query.tanstack.com ๋ฐฐ๊ฒฝ server state ์ฌ์ฉ ์ ๋ฐ์ํ ์ ์๋ ๋ฌธ์ ์ ์ ๋ค์๊ณผ ๊ฐ๋ค. caching deduping(๋ฐ์ดํฐ ์ค๋ณต ์ ๊ฑฐ) update "out of date" data / know when is it reflecting updates data pagination optimization, lazy loading data memory management, garba..
query๊ฐ ์ค๋ ๋์๋ค๋ ๊ฒ์ ํ๋จํ๊ณ ๋ค์ fetchํด์ฌ ๋, queryClient.invalidateQueries ํจ์๋ฅผ ์ฌ์ฉํ๋ค. https://react-query.tanstack.com/guides/query-invalidation Query Invalidation Query Invalidation Waiting for queries to become stale before they are fetched again doesn't always work, especially when you know for a fact that a query's data is out of date because of something the user has done. For that purpose, the Quer..
query์ ๋ค๋ฅด๊ฒ CUD์ ์ฌ์ฉ๋๋ค. https://react-query.tanstack.com/guides/mutations Mutations Subscribe to our newsletter The latest TanStack news, articles, and resources, sent to your inbox. react-query.tanstack.com ์ฌ์ฉ์์ const mutation = useMutation(newTodo => axios.post('/todos', newTodo)) return ( {mutation.isLoading ? ( 'Adding todo...' ) : ( {mutation.isError ? ( An error occurred: {mutation.error.mes..
๊ธฐ๋ณธ ์ฌ์ฉ const info = useQuery('unique_key', fetchData); // fetchData๋ promise ๋ฐํ uniqueํ key๋ก ์ ์ํ๋ฉฐ, key์ ๋ฌถ์ด๋ ๋ฐ์ดํฐ๋ ๋น๋๊ธฐ ๋ฐ์ดํฐ์ด๋ค. useQuery๊ฐ ๋ฐํํ๋ result๋ ๋น๋๊ธฐ ๋ฐ์ดํฐ์ ์ํ๋ฅผ ๋ด๊ณ ์๋ค. ์ํ loading isLoading์ด true๊ฐ ๋๋ค. error isError๊ฐ true๊ฐ ๋๋ฉฐ, error์ ์๋ฌ ์ ๋ณด๊ฐ ๋ด๊ธด๋ค. success isSuccess๊ฐ true๊ฐ ๋๋ฉฐ, data์ ์ ๋ณด๊ฐ ๋ด๊ธด๋ค. idle ์ฌ์ฉ ์์ const { isLoading, isError, data, error } = useQuery('key', fetchData); // const { status, data, erro..
์น ํ์ด์ง์์ ์ฑ ๋ด๋ถ๋ก ์ ์ ๋ฅผ ์ด๋ํ๊ธฐ ์ํด ๋ฅ๋งํฌ๋ฅผ ์ฌ์ฉํ๋ค. ์ฆ, ๋ฅ๋งํฌ๋ ๋ชจ๋ฐ์ผ ์ฑ ๋ด์ ํน์ ์ฝํ ์ธ ๋ก ์ด๋ํ ์ ์๋ ๋ชจ๋ ๋งํฌ๋ฅผ ์๋ฏธํ๋ค. Deeplink ์ข ๋ฅ URL Scheme ๊ณ ์ ์ฑ://์ฝํ ์ธ ์ ํํ์ด๋ค. ์ฑ์ด ๊น๋ ค์์ ๋ ํน์ ์ฑ์ ํน์ ํ์ด์ง๋ก ์ด๋ํ๋ค. ์ฑ ๋ฏธ์ค์น ์ ๋์ํ์ง ์๋๋ค. Universal Link IOS์์๋ง ๋์ํ๋ ๋ฅ๋งํฌ์ด๋ค. ์ ๋๋ฒ์ ๋งํฌ๋ ์ฑ์์ ํ์ฉํ ๋๋ฉ์ธ์ ๋ฑ๋กํด์ฃผ์ด์ผ ํ๋ฉฐ, ์น ํ๋ก ํธ์์ .well-known/apple-app-site-association ํ์ผ์ ์ ์ํ์ฌ ํ์ฉํ path๋ฅผ ์ง์ ๊ฒฐ์ ํ ์ ์๋ค. ์ ๋๋ฒ์ ๋งํฌ๋ฅผ ์ฌ์ฉํ๋ฉด ๋ชจ๋ฐ์ผ ์น์ผ๋ก ํน์ Path์ ํ์ด์ง์ ์ ์ ์ ์ฑ ๋ด์ ํด๋น ์์น๋ก ์ ์ ๋ฅผ ์ด๋ ์์ผ์ค ์ ์๋ค. App Link ..
Comment