expo-auth-session for Instagram auth doesn’t work if
- I haven’t previously logged in Safari
and - I have Instagram app installed on my physical device.
If these two conditions are true, I can finish the auth flow, then I am redirected back to my app as usual, but auth modal is still the same and I don’t get any result.
If I delete Instagram app on my physical device, then it works fine.
I doubt that when the auth flow starts, for a short moment, I am redirected to Instagram app before being redirected to the auth route. The problem might be somewhere here.
const apiBaseURL = 'https://api.instagram.com/oauth';
//TODO: Replace appId with yours
const appId = '99999999999';
export const isAuthSessionUseProxy = () =>
Constants.appOwnership === AppOwnership.Expo;
export const getAuthSessionRedirectUrl = () =>
AuthSession.makeRedirectUri({ useProxy: isAuthSessionUseProxy() });
export const fetchIGCode = async () => {
WebBrowser.maybeCompleteAuthSession();
const redirectUrl = getAuthSessionRedirectUrl();
const discovery = {
authorizationEndpoint: `${apiBaseURL}/authorize`,
tokenEndpoint: `${apiBaseURL}/token`,
};
const request = await AuthSession.loadAsync(
{
clientId: appId,
redirectUri: redirectUrl,
scopes: ['user_profile', 'user_media'],
responseType: AuthSession.ResponseType.Code,
},
discovery
);
const result = await request.promptAsync(discovery, {
useProxy: isAuthSessionUseProxy(),
});
return result;
};
Expo Workflow: managed
expo: ^42.0.0 => 42.0.3
"expo-auth-session": "~3.3.1",
"expo-web-browser": "~9.2.0",
"expo-random": "~11.2.0",
"expo-linking": "~2.3.1",
"expo-constants": "~11.0.1",