Managing Tokens
Obtaining Token
You can retrieve it using getAccessToken()
.
It is defined as follows.
export function getAccessToken(): Promise<KakaoAccessTokenInfo>
The type is as follows.
export interface KakaoAccessTokenInfo {
id?: number;
appId: number;
expiresIn: number;
}
Example
getAccessToken()
Setting Access Token (Web)
You can store the value received as code
in the search parameter of the Redirect URL upon successful web login using the setAccessTokenWeb()
function for Kakao SDK access.
Example
Call setAccessTokenWeb
on the page configured as the login Redirect URl as shown below.
const { code } = useGlobalSearchParams<{ code?: string }>();
useEffect(() => {
if (code) {
setAccessTokenWeb(code);
}
}, [code]);