Authentication with Instagram using AuthSession from Expo React Native

Please provide the following:

  1. SDK Version: 36.0.0
  2. Platforms(Android/iOS/web/all): Android device connected by usb

I really need a help for this problem I am having. What I want to do is logging in the user with their instagram account. Theses are what I did

expo sdk version is 36.0.0
Created Facebook app and added instagram basic display product in Facebook development console.
In instagram product Valid OAuth Redirect URIs settings I put " https://auth.expo.io/expo-id/app-slug" and I am pretty sure that is correct.

And this is code


export function InstagramLoginButton() {
      const [ token, setToken ] = useState("");
      const instagram_App_id = "instagram-app-id";
      const redirectUrl = AuthSession.getRedirectUrl();
      let result = null;

      return (
        <View>
        <Button                 
        onPress={ async () => {

          result = await AuthSession.startAsync(
            {
              authUrl:
                `https://api.instagram.com/oauth/authorize/?client_id=${instagram_App_id}` +
                `&redirect_uri=${encodeURIComponent(redirectUrl)}` +
                `&response_type=code` +
                `&scope=user_profile`
            }
          );
          setToken({ result });
        }}
        >
        Instagram Login
        </Button>
        { token ? <Text>{JSON.stringify(token)}</Text> : null }
        </View>
      );
    }

After clicking button, it redirect to the page says

The app at exp://127.0.0.1:19000/--/expo-auth-session is asking you to sign into another service. Is this OK? with Yes and No button So I clicked Yes.

Then It redirects me to authUrl and display errors

{"error_type": "OAuthException", "code": 400, "error_message": "Invalid redirect_uri"}

So I have some questions

  1. Why is my redirect_uri is not working?
  2. When I click a login button, I expected the instagram login screen instead of saying “The app at exp://127.0.0.1:19000/–/expo-auth-session is asking you to sign into another service. Is this OK?” Why not showing instagram login page?
  3. In Instagram basic display docs says “Note that Basic Display is not an authentication tool. Data returned by the API cannot be used to authenticate your app users or log them into your app. If your app uses API data to authenticate users, it will be rejected during App Review. If you need an authentication solution, use Facebook Login instead.” How can I instagram login using facebook login?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.