hungdev / react-native-instagram-login

a react native instagram login component (support android & ios). Pull requests are welcome!
https://www.npmjs.com/package/react-native-instagram-login
184 stars 103 forks source link

403 Error [URGENT] #102

Open Dlas1212 opened 2 years ago

Dlas1212 commented 2 years ago

Calling 'https://api.instagram.com/oauth/access_token' returning Forbidden 403. Started yesterday randomly.

I am on the latest version too.

unixkapl commented 2 years ago

+1

alyn3d commented 2 years ago

+1

saurabhjayx commented 2 years ago

same happening with me

alyn3d commented 2 years ago

As far as I can tell there's an issue with the redirectUrl Still haven't figured how to solve it.

Tymofiev commented 2 years ago

What I noticed is that when it's first time I logged into IG then it worked just fine, and if it's second attempt so browser kinda had already remembered my account - it failed with 403.

I suppose it is the cookies issue, as it returned html page with the text that said smth about cookies couple times.

hungdev commented 2 years ago

What I noticed is that when it's first time I logged into IG then it worked just fine, and if it's second attempt so browser kinda had already remembered my account - it failed with 403.

I suppose it is the cookies issue, as it returned html page with the text that said smth about cookies couple times.

I don't think so, because I tried with props incognito but it still gets that issue.

sujay-bidchat commented 2 years ago

+1

sujay-bidchat commented 2 years ago

Adding to all the above comments. This issue comes only for Android. It works perfectly fine for iOS every time. Even it works every time on Postman too.

nimit07 commented 2 years ago

@sujay-bidchat were you able to find a solution for this?

sujay-bidchat commented 2 years ago

@nimit07 I have found a workaround for this issue. You can send the "code" to BE (Back End) and let them get the access_token for you. This is what I've done.

@sujay-bidchat were you able to find a solution for this?

saurabh-cimpress commented 2 years ago

Having the same issue. Any workaround or Fix?

alyn3d commented 2 years ago

Workaround that I ended up using is this

sujay-bidchat commented 2 years ago

Workaround that I ended up using is this

I have done the same as mentioned above.

duongquang1611 commented 1 year ago

does anyone have a solution?

pnishith commented 1 year ago

Try in a this way:

const data = {
  client_id: clientId,
  client_secret: clientSecret,
  grant_type: 'authorization_code',
  redirect_uri: redirectUri,
  code: authorizationCode,
};

const url = 'oauth/access_token';

const api = axios.create({
  baseURL: 'https://api.instagram.com/',
  withCredentials: false, // Disable automatic handling of cookies
});

const config = {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
  },
};

api
    .post(url, new URLSearchParams(data).toString(), config)
    .then((response) => {
      console.log(response);
      // Handle the response containing the access token
      const accessToken = response.data.access_token;
      // Use the access token to make further API requests
      // ...
    })
    .catch((error) => {
      console.log(error);
      // Handle any error that occurred during the request
    });