Fix Instagram Logout Failure & Add Graceful Handling for Deprecated OAuth API#700
Open
ashfaq3112 wants to merge 1 commit intoMrSwitch:mainfrom
Open
Fix Instagram Logout Failure & Add Graceful Handling for Deprecated OAuth API#700ashfaq3112 wants to merge 1 commit intoMrSwitch:mainfrom
ashfaq3112 wants to merge 1 commit intoMrSwitch:mainfrom
Conversation
dc9b406 to
f6f63dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Instagram has deprecated its standalone OAuth API, which breaks the login and logout flows for the instagram provider in hello.js. As a result:
Login always returns "cancelled" or closes the popup unexpectedly.
Logout always fails with 405 Method Not Allowed or CSP/CORS blocking.
Since Instagram no longer supports its legacy OAuth endpoints, client-side login cannot be restored.
However, logout can be improved to avoid errors and maintain a clean local session.
This PR updates the Instagram provider to use a modernized logout approach and documents Instagram’s API deprecation.
Fixes Included
🔹 1. New logout handler using POST + CSRF
The old GET request to /accounts/logout/ is no longer supported.
This PR:
Switches to POST https://www.instagram.com/accounts/logout/
Extracts CSRF token automatically from cookies (csrftoken or csrfmiddlewaretoken)
Sends credentials: "include" so Instagram session cookies are forwarded
Handles CORS failures gracefully (Instagram now blocks all cross-site logout)
Always clears the local HelloJS session and resolves the callback
🔹 2. Safe fallback for CORS-blocked responses
Even though Instagram blocks the response, hello.js still:
Clears local session
Fires the auth.logout event
Prevents unhandled exceptions
🔹 3. Documentation update
Added notes explaining that:
Instagram’s standalone OAuth API has been deprecated
Login cannot function fully on client-side JS
Full authentication now requires Facebook Graph API / Instagram Basic Display API
Notes
Instagram’s current authentication flow cannot work fully client-side because:
Old OAuth endpoints have been removed
/accounts/logout/ requires POST + CSRF
Instagram does not provide CORS headers
OAuth must be completed server-side using Facebook Graph API
This PR ensures hello.js handles the logout more gracefully and informs developers about the required migration path.
Code Changes
Updated Logout Function
logout: function (callback, p) {
},
How to Test
1.Build the repo:
2.Use the test page:
hello('instagram').logout({ force: true })
.then(r => console.log("LOGOUT:", r));
3.Expected Behavior:
->No uncaught errors
->auth.logout event is triggered
->Local session removed
->Network tab shows a POST to /accounts/logout/
->Response is blocked by CORS (normal)
Final Notes
This PR does not attempt to restore Instagram login (which is impossible on the client due to API deprecation). Instead, it:
✔ Fixes the logout errors
✔ Ensures consistent behavior
✔ Removes confusing CSP/CORS failures
✔ Updates documentation to reflect Instagram’s API changes
This improves developer experience and avoids false expectations.