mastodon / mastodon/documentation

Mastodon OAuth Login Bug With 2FA

Open
#1,872 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
SCSS
Stars
1.7k
Forks
978
PR merge metrics
No merged PRs in 30d

Description

Hello.

I am developing a small PHP application that allows users to log in with Mastodon using OAuth.

The login flow works normally for accounts without two factor authentication:

  1. User clicks login
  2. Mastodon authorization page opens
  3. User approves the application
  4. User is redirected to my callback.php
  5. Login completes successfully

However when a user has 2FA enabled on their Mastodon account, the behavior changes.

The flow becomes:

  1. User approves the application
  2. Mastodon asks for the 2FA code
  3. User enters the code
  4. After successful verification the user is not redirected to my callback URL

Because of this the OAuth login process never finishes.

My question is:

Is there an additional step required in the OAuth flow when 2FA is enabled
or could this be a bug with the redirect after 2FA verification

Has anyone experienced this before?

Thank you.

auth_check.php
callback.php
login.php
mastodon_helpers.php
config.php

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the attached auth_check.php, login.php, callback.php, and mastodon_helpers.php files to trace the OAuth redirect handling. Reproduce the flow with and without Mastodon 2FA and determine whether the callback is reached after verification. Done means identifying whether an additional OAuth step or a redirect defect is responsible and documenting the result.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.