react-native-instagram-login icon indicating copy to clipboard operation
react-native-instagram-login copied to clipboard

onLoginFailure being triggered every time

Open tuladharjaa opened this issue 5 years ago • 49 comments

The login was working fine but after adding another Instagram tester user the "onLoginFailure" keeps triggering instead of "onLoginSuccess".

tuladharjaa avatar Nov 02 '20 05:11 tuladharjaa

I get this as well, it also gives a code in error response object, insead of token and HTML page is logged out into console.

Tymofiev avatar Nov 02 '20 10:11 Tymofiev

i am also facing that issue. Instagram Login was working yesterday also. Now its throwing some 403 forbidden issue for android only

Dhanraj-bidchat avatar Nov 02 '20 14:11 Dhanraj-bidchat

Also facing the problem, Android only

rafalzawadzki avatar Nov 02 '20 17:11 rafalzawadzki

I have also the same problem, both on real android device and ios device. Somehow the login is working correctly on ios simulator ... Which is rather strange, the code executed being exactly the same.

The first code is correctly retrieved but it's the request to https://api.instagram.com/oauth/access_token which gets a 403 response (but not on ios simulator)

Nico-Guyon avatar Nov 02 '20 19:11 Nico-Guyon

Found the issue but this is rather unexplainable ...

Instagram changed the fields app_id and app_secret used with access_token to client_id and client_secret. https://developers.facebook.com/docs/instagram-basic-display-api/reference/oauth-access-token

So in the file instagram.js from your react-native-instagram-login replace the following code

form.append('app_id', appId);
form.append('app_secret', appSecret);
form.append('grant_type', 'authorization_code');
form.append('redirect_uri', redirectUrl);
form.append('code', code);

with

form.append('client_id', appId);
form.append('client_secret', appSecret);
form.append('grant_type', 'authorization_code');
form.append('redirect_uri', redirectUrl);
form.append('code', code)

And your login should work again.

Why the requests are working on the ios simulator and failing with a real device is totally beyond me though ...

Nico-Guyon avatar Nov 02 '20 21:11 Nico-Guyon

athorisation on instagram is returning code key instead of acess token key, as mentioned above you can make changes in libraray's main file accordingly. here it is: https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

Rramandeep avatar Nov 04 '20 09:11 Rramandeep

i forked and fixed the issue. Here is my package: "react-native-instagram-login": "git+https://github.com/bidchatindia/react-native-instagram-login.git#v2" You can use my package till they give update to this package.

Dhanraj-bidchat avatar Nov 04 '20 10:11 Dhanraj-bidchat

why not to copy lib code locally and change untill lib not updated.

Rramandeep avatar Nov 04 '20 10:11 Rramandeep

@Rramandeep Our app is already live on store. You will have to give new update to playstore for that anyways. i made codepush to my users and done!

Dhanraj-bidchat avatar Nov 04 '20 10:11 Dhanraj-bidchat

@Dhanraj-bidchat no offence bro, but my app is under developement that's why.

Rramandeep avatar Nov 04 '20 10:11 Rramandeep

@Rramandeep thats fine bro. Nobody is forced to use my package. Its for beginners who may find it difficult to do so.

Dhanraj-bidchat avatar Nov 04 '20 10:11 Dhanraj-bidchat

I updated the library, so you can remove the old version and install the new version. Feel free to comment here. Love guys.

hungdev avatar Nov 04 '20 16:11 hungdev

Found the issue but this is rather unexplainable ...

Instagram changed the fields app_id and app_secret used with access_token to client_id and client_secret. https://developers.facebook.com/docs/instagram-basic-display-api/reference/oauth-access-token

So in the file instagram.js from your react-native-instagram-login replace the following code

form.append('app_id', appId);
form.append('app_secret', appSecret);
form.append('grant_type', 'authorization_code');
form.append('redirect_uri', redirectUrl);
form.append('code', code);

with

form.append('client_id', appId);
form.append('client_secret', appSecret);
form.append('grant_type', 'authorization_code');
form.append('redirect_uri', redirectUrl);
form.append('code', code)

And your login should work again.

Why the requests are working on the ios simulator and failing with a real device is totally beyond me though ...

You also change the appId to client_id

let ig_uri = `https://api.instagram.com/oauth/authorize/?client_id=${appId}&redirect_uri=${redirectUrl}&response_type=${responseType}&scope=${scopes.join(',')}`;

kiritm-nimblechapps avatar Nov 05 '20 05:11 kiritm-nimblechapps

@kiritm-nimblechapps I forgot it. Thank u. i updated.

hungdev avatar Nov 05 '20 08:11 hungdev

Getting this on the "onLoginFailure"

Object { _: "" }

The latest package was working a while ago.

tuladharjaa avatar Nov 10 '20 05:11 tuladharjaa

@tuladharjaa can you give me steps to get onLoginFailure? or send me a video about this

hungdev avatar Nov 10 '20 06:11 hungdev

The screen capture is on the following link: https://drive.google.com/file/d/17zwnpqwRmwP11FqCm6DdBk9p-8sqA_5a/view?usp=sharing

The code I have used: <Instagram ref={instagram => { this.instagramLogin = instagram; }} appId={config.igAppId} appSecret={config.igAppSecret} redirectUrl={config.igRedirectUrl} scopes={['user_profile', 'user_media']} onLoginSuccess={this.setIgToken} onLoginFailure={(data) => console.warn("Failure", data)} onClose={() => this.props.navigation.goBack(null)} />

tuladharjaa avatar Nov 10 '20 06:11 tuladharjaa

Tried to see if I had a login problem again on my app but it's working on iOS both device and simulator for me right now.

@tuladharjaa can you step into the library with the debugger and see what are the result of the instagram requests ? Does anyone else also have a login problem again ?

Nico-Guyon avatar Nov 10 '20 06:11 Nico-Guyon

The returned URL from WebView does not contain the codes. It just returns the redirectURL

I am getting this on an Android device.

tuladharjaa avatar Nov 10 '20 07:11 tuladharjaa

@tuladharjaa you tried android login with same user that you loged in on iOS?? If your app is not live, always add new user as test user if not done

Dhanraj-bidchat avatar Nov 10 '20 09:11 Dhanraj-bidchat

@tuladharjaa you tried android login with same user that you loged in on iOS?? If your app is not live, always add new user as test user if not done

I have added the account as tester and was working previously on Android. I have not tried it on iOS.

tuladharjaa avatar Nov 10 '20 09:11 tuladharjaa

@tuladharjaa can you try one common test account on both and let us know please?

Dhanraj-bidchat avatar Nov 10 '20 09:11 Dhanraj-bidchat

@tuladharjaa can you try one common test account on both and let us know please?

On iOS it is working fine.

tuladharjaa avatar Nov 10 '20 10:11 tuladharjaa

Just tried with an android emulator and it's working fine on my end. I'll test later with a real android device and let you know if I can also reproduce the login pb.

Nico-Guyon avatar Nov 10 '20 10:11 Nico-Guyon

I just checked it again, it still works normally. I don't know the exact error.

hungdev avatar Nov 12 '20 14:11 hungdev

I installed the version 2.0.2 and then made changes on the Instagram.js file and it is working fine.

tuladharjaa avatar Nov 12 '20 19:11 tuladharjaa

Hey guys! Thanks for your efforts.. but, I'm receiving on onLoginFailure an object with the code. Anyone can help me?

denisprado avatar Nov 13 '20 19:11 denisprado

@denisprado show me your error, your code and your current version you are using

hungdev avatar Nov 16 '20 03:11 hungdev

@hungdev HI. My component is like that:

<InstagramLogin ref={ref => (instagramLogin = ref)} appId={igProd.appId} responseType="code" appSecret={igProd.appSecret} scopes={['user_profile', 'user_media']} redirectUrl={igProd.redirectUrl} onLoginSuccess={setIgToken} onLoginFailure={data =>console.log(data.code)} />

and I'm using the last version, 2.0.4. The error is the onLoginSuccess not receiving any data. I'm receiving a code onLoginFailure.

denisprado avatar Nov 16 '20 10:11 denisprado

@denisprado show me error from onLoginFailure func

hungdev avatar Nov 16 '20 16:11 hungdev