Skip to content

fix(social-auth): restore Instagram OAuth scopes for pages, insights and comments#88

Open
dvlexp wants to merge 1 commit into
evolution-foundation:mainfrom
dvlexp:fix/social-auth-instagram-scope
Open

fix(social-auth): restore Instagram OAuth scopes for pages, insights and comments#88
dvlexp wants to merge 1 commit into
evolution-foundation:mainfrom
dvlexp:fix/social-auth-instagram-scope

Conversation

@dvlexp
Copy link
Copy Markdown

@dvlexp dvlexp commented May 23, 2026

Problem

The Instagram OAuth flow was using a legacy scope set (instagram_basic, instagram_content_publish, publish_video) that is no longer accepted by the Meta app review process for the Graph API v18+. This caused the OAuth authorization to fail for analytics and engagement tracking features.

Solution

Replace the legacy scope set with the Meta Graph v18+ recommended permissions:

Old scope New scope
instagram_basic pages_show_list
instagram_manage_insights pages_read_engagement
pages_show_list instagram_manage_insights
instagram_content_publish instagram_manage_comments
publish_video (removed — not needed for analytics)

Files Changed

  • social-auth/auth/instagram.py — single-line scope string update

Test Plan

  • Trigger the Instagram OAuth flow via make social-auth
  • Authorize the app — no "invalid scope" error from Meta
  • Verify analytics endpoints (/me/media, /me/insights) return data after authorization

Summary by Sourcery

Update Instagram OAuth scope set to align with Meta Graph API v18+ requirements for analytics and engagement features.

Bug Fixes:

  • Fix Instagram OAuth authorization failures caused by deprecated or invalid scopes.

Enhancements:

  • Adjust requested Instagram permissions to the minimal set needed for pages listing, insights, and comment management.

…ents

Replaced legacy scope set (instagram_basic + content_publish + publish_video)
with the Meta Graph v18+ recommended set:
- pages_show_list
- pages_read_engagement
- instagram_manage_insights
- instagram_manage_comments

Older scopes were rejected by the new Meta app review flow.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 23, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the Instagram OAuth connection flow to request the new, Meta Graph v18+–compliant set of permissions so that analytics and engagement tracking continue to work without scope errors.

Sequence diagram for updated Instagram OAuth scope usage

sequenceDiagram
    actor User
    participant AppBackend as AppBackend(connect)
    participant InstagramOAuth as Instagram_OAuth_Server

    User->>AppBackend: GET /auth/instagram/connect
    AppBackend->>AppBackend: connect()
    AppBackend->>AppBackend: _callback_url()
    AppBackend->>AppBackend: urlencode(scope="pages_show_list,pages_read_engagement,instagram_manage_insights,instagram_manage_comments")
    AppBackend-->>User: 302 Location: https://www.facebook.com/v18.0/dialog/oauth?...
    User->>InstagramOAuth: Open authorization URL with new scopes
    InstagramOAuth-->>User: Consent screen for pages and insights permissions
    User-->>InstagramOAuth: Approve requested scopes
    InstagramOAuth-->>User: Redirect to callback_url with code and state
    User->>AppBackend: GET callback_url?code=...&state=...
Loading

File-Level Changes

Change Details Files
Update Instagram OAuth scope string to use Meta Graph v18+–approved permissions.
  • Replace legacy Instagram scopes with the new combination of page and Instagram permissions required for analytics and engagement features.
  • Remove the deprecated publish_video permission from the requested scope set, since it is not needed for analytics.
social-auth/auth/instagram.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider extracting the scope list into a named constant (or helper) so future Meta permission changes can be updated in one place and better documented in code.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the scope list into a named constant (or helper) so future Meta permission changes can be updated in one place and better documented in code.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant