File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,19 @@ public function is_authenticated(): bool {
3333 ! empty ( $ config ['app_password ' ] );
3434 }
3535
36+ /**
37+ * Get the Bluesky handle.
38+ *
39+ * Bluesky stores the handle in config (not account) because it uses
40+ * app-password auth rather than OAuth token exchange.
41+ *
42+ * @return string|null Handle or null
43+ */
44+ public function get_username (): ?string {
45+ $ config = $ this ->get_config ();
46+ return ! empty ( $ config ['username ' ] ) ? $ config ['username ' ] : null ;
47+ }
48+
3649 public function get_config_fields (): array {
3750 return array (
3851 'username ' => array (
Original file line number Diff line number Diff line change @@ -327,14 +327,17 @@ function ( $long_lived_token_data ) {
327327 $ user_profile_name = $ profile_info ['name ' ] ?? 'ErrorFetchingName ' ;
328328 }
329329
330+ $ page_name = $ page_credentials ['name ' ] ?? '' ;
331+
330332 return array (
331333 'user_access_token ' => $ access_token ,
332334 'page_access_token ' => $ page_credentials ['access_token ' ],
333335 'token_type ' => 'bearer ' ,
334336 'user_id ' => $ user_profile_id ,
337+ 'username ' => $ page_name ,
335338 'user_name ' => $ user_profile_name ,
336339 'page_id ' => $ page_credentials ['id ' ],
337- 'page_name ' => $ page_credentials [ ' name ' ] ,
340+ 'page_name ' => $ page_name ,
338341 'authenticated_at ' => time (),
339342 'token_expires_at ' => $ token_expires_at ,
340343 );
Original file line number Diff line number Diff line change @@ -116,18 +116,8 @@ public function get_user_id(): ?string {
116116 return $ account ['user_id ' ];
117117 }
118118
119- /**
120- * Get stored Instagram username
121- *
122- * @return string|null Username or null
123- */
124- public function get_username (): ?string {
125- $ account = $ this ->get_account ();
126- if ( empty ( $ account ) || ! is_array ( $ account ) || empty ( $ account ['username ' ] ) ) {
127- return null ;
128- }
129- return $ account ['username ' ];
130- }
119+ // get_username() is inherited from BaseAuthProvider.
120+ // Instagram already stores username under the canonical 'username' key.
131121
132122 /**
133123 * Get authorization URL for Instagram OAuth
Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ function ( $token_data ) {
185185 'token_type ' => 'bearer ' ,
186186 'token_expires_at ' => $ expires_at ,
187187 'person_id ' => $ profile ['sub ' ] ?? '' ,
188+ 'username ' => $ profile ['name ' ] ?? 'Unknown ' ,
188189 'name ' => $ profile ['name ' ] ?? 'Unknown ' ,
189190 'email ' => $ profile ['email ' ] ?? '' ,
190191 'picture ' => $ profile ['picture ' ] ?? '' ,
Original file line number Diff line number Diff line change @@ -169,11 +169,14 @@ function ( $long_lived_token_data ) {
169169 );
170170 }
171171
172+ $ page_name = $ posting_entity_info ['name ' ] ?? 'Unknown Page/User ' ;
173+
172174 return array (
173175 'access_token ' => $ access_token ,
174176 'token_type ' => 'bearer ' ,
177+ 'username ' => $ page_name ,
175178 'page_id ' => $ posting_entity_info ['id ' ],
176- 'page_name ' => $ posting_entity_info [ ' name ' ] ?? ' Unknown Page/User ' ,
179+ 'page_name ' => $ page_name ,
177180 'authenticated_at ' => time (),
178181 'token_expires_at ' => $ token_expires_at ,
179182 );
Original file line number Diff line number Diff line change @@ -177,12 +177,15 @@ public function handle_oauth_callback() {
177177 $ api_key ,
178178 $ api_secret ,
179179 function ( $ access_token_data ) {
180- // Build account data from Twitter response
180+ $ screen_name = $ access_token_data ['screen_name ' ] ?? null ;
181+
182+ // Build account data from Twitter response.
181183 return array (
182184 'access_token ' => $ access_token_data ['oauth_token ' ],
183185 'access_token_secret ' => $ access_token_data ['oauth_token_secret ' ],
184186 'user_id ' => $ access_token_data ['user_id ' ] ?? null ,
185- 'screen_name ' => $ access_token_data ['screen_name ' ] ?? null ,
187+ 'username ' => $ screen_name ,
188+ 'screen_name ' => $ screen_name ,
186189 'last_verified_at ' => time (),
187190 );
188191 },
You can’t perform that action at this time.
0 commit comments