ExpoAdvanced
expo-auth-session — OAuth (Google) login
PKCE-based OAuth flow — expo-auth-session দিয়ে sign-in।
6টি অংশবাংলা ভাষায়
তৃতীয়-পক্ষ OAuth (Google, GitHub)-এ `expo-auth-session` — PKCE + deep-link redirect-এর standard flow।
terminalbash
bash
npx expo install expo-auth-session expo-web-browserlib/useGoogleAuth.tsts
ts
import * as AuthSession from "expo-auth-session";
import * as WebBrowser from "expo-web-browser";
WebBrowser.maybeCompleteAuthSession();
const config = {
clientId: "YOUR_CLIENT_ID",
scopes: ["openid", "profile", "email"],
redirectUri: AuthSession.makeRedirectUri({ scheme: "tasktrack" }),
};
export function useGoogleAuth() {
return AuthSession.useAuthRequest({
...config,
authorizationEndpoint:
"https://accounts.google.com/o/oauth2/v2/auth",
tokenEndpoint: "https://oauth2.googleapis.com/token",
});
}redirectUri — tasktrack:// — app.json-এ scheme আগে থেকেই ঠিক আছে। Result handle:
const [request, response, promptAsync] = useGoogleAuth();
useEffect(() => {
if (response?.type === "success") {
const token = response.params.access_token;
saveToken(token);
}
}, [response]);
promptAsync(); // button-এ call করবেনclient secret নয়
Mobile OAuth = public client — client_secret কখনও অ্যাপ-এ রাখবেন না। Token server-এ verify করে session complete করুন (PKCE safety)।
শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।