Arpine Harutyunyan
Arpine Harutyunyan

Reputation: 19

Twitter API v2: 403 Forbidden - "Use keys from Twitter Developer App attached to a Project"

I've been using Laravel/Socialite to interact with the Twitter API v2 for a while, and everything was working fine until last week. I'm encountering a "403 Forbidden" error with the message:

 Client error: `GET https://api.twitter.com/2/users/me?user.fields=profile_image_url` resulted in a `403 Forbidden` {"client_id":"xxxxxxx","detail":"When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project"}

I'm on a free plan, and I've confirmed that my Twitter Developer App is associated with a Project. Here are some details about my setup:

Laravel/framework: "^9.19", Laravel/Socialite version: "^5.5" Twitter Developer App details: [App Permissions: 'users.read', 'tweet.read'] Code snippet where the error occurs:

$user = Socialite::driver('twitter-oauth-2')->user();

I'm confused about why this issue suddenly appeared and how to resolve it. Any guidance or insights would be greatly appreciated!

Thank you in advance!

Upvotes: 0

Views: 856

Answers (3)

Arpine Harutyunyan
Arpine Harutyunyan

Reputation: 19

I saw my app on Standalone Apps and on project with V2 ACCESS, and decide that my app is in project, but no. I added project, it removed from Standalone Apps and my request start to work.

Upvotes: 0

deanhowe
deanhowe

Reputation: 1

I scratched my head for a while about this - even forked repos.

However I think this is about how the App is set-up in the X/Twitter developer portal.

I think they must have updated the developer portal.

You now need to add a Project (you get 1 on the free tier) - when creating the Project you can add the App. Quite sure this has solved the error for my install.

Upvotes: 0

wanghq
wanghq

Reputation: 1356

Not sure about the exact cause.

The user() calls https://api.twitter.com/2/users/me (https://github.com/laravel/socialite/blob/5.x/src/Two/TwitterProvider.php#L57-L65) which is supported by the free plan(https://developer.twitter.com/en/portal/products/free).

I tried that api with postman and can confirm that I can get back the user successfully.

Upvotes: 0

Related Questions