Commit 11f8a1e
Fix WebLoginMethodHandler to properly handle custom redirect URIs
Summary:
This change enables proper handling of custom redirect URIs in WebView login flows by launching them as Android intents instead of processing them as Facebook callbacks, while preserving standard Facebook login behavior for empty/default redirect URIs.
## Key Changes:
- WebLoginMethodHandler.onComplete(): Added custom redirect URI detection and early
return to avoid interfering with custom redirect handling
- CustomRedirectWebDialog: New WebDialog subclass that overrides parseResponseUri()
to launch custom URIs as Android intents via Intent.ACTION_VIEW
- AuthDialogBuilder: Modified to use original request to determine when to create
CustomRedirectWebDialog vs standard WebDialog
## Fixes:
- Black screen issue by preserving normal WebDialog loading behavior
- ERR_UNKNOWN_URL_SCHEME error when redirect_uri is empty by using original request
- "Login cancelled" error for custom redirects by avoiding completion callbacks
- Proper intent launching with full URL including query parameters
## Test Updates:
- Fix NullPointerException in LoginManager.retrieveLoginStatusImpl with null safety check
- Add missing FacebookSdk.getRedirectURI() mock in LoginManagerTest setup
- Fix WebViewLoginMethodHandlerTest compilation errors by adding missing request parameter
- Update tests to properly handle custom vs standard redirect URI behavior differences
- Add comprehensive test coverage for custom redirect URI scenarios (success, cancel, error)
- Fix missing Mockito imports in test files
This ensures custom redirect URIs work properly via Android system handling while maintaining full backward compatibility for standard Facebook login flows.
Differential Revision: D82615611
fbshipit-source-id: 8944e117cacd25089641cb4cda3c4f09f9ed976f1 parent 4b08fce commit 11f8a1e
File tree
3 files changed
+154
-28
lines changed- facebook-common/src
- main/java/com/facebook/login
- test/kotlin/com/facebook/login
3 files changed
+154
-28
lines changedLines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | 139 | | |
141 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
142 | 176 | | |
143 | 177 | | |
144 | 178 | | |
| |||
Lines changed: 34 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
152 | 156 | | |
153 | 157 | | |
154 | 158 | | |
155 | | - | |
156 | | - | |
| 159 | + | |
| 160 | + | |
157 | 161 | | |
158 | 162 | | |
159 | 163 | | |
| |||
178 | 182 | | |
179 | 183 | | |
180 | 184 | | |
181 | | - | |
182 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
| |||
188 | 193 | | |
189 | 194 | | |
190 | 195 | | |
191 | | - | |
| 196 | + | |
192 | 197 | | |
193 | 198 | | |
194 | 199 | | |
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | 203 | | |
199 | | - | |
200 | | - | |
201 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
202 | 223 | | |
203 | 224 | | |
204 | 225 | | |
| |||
210 | 231 | | |
211 | 232 | | |
212 | 233 | | |
213 | | - | |
214 | | - | |
| 234 | + | |
| 235 | + | |
215 | 236 | | |
216 | 237 | | |
217 | 238 | | |
| |||
234 | 255 | | |
235 | 256 | | |
236 | 257 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | 258 | | |
241 | 259 | | |
242 | 260 | | |
| |||
Lines changed: 85 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | | - | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | | - | |
| 106 | + | |
| 107 | + | |
103 | 108 | | |
104 | 109 | | |
105 | 110 | | |
| |||
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
| 122 | + | |
117 | 123 | | |
118 | 124 | | |
119 | | - | |
| 125 | + | |
| 126 | + | |
120 | 127 | | |
121 | 128 | | |
122 | 129 | | |
| |||
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
213 | | - | |
214 | | - | |
| 220 | + | |
| 221 | + | |
215 | 222 | | |
216 | 223 | | |
217 | 224 | | |
| |||
230 | 237 | | |
231 | 238 | | |
232 | 239 | | |
233 | | - | |
| 240 | + | |
| 241 | + | |
234 | 242 | | |
235 | | - | |
| 243 | + | |
236 | 244 | | |
237 | 245 | | |
238 | 246 | | |
| |||
252 | 260 | | |
253 | 261 | | |
254 | 262 | | |
| 263 | + | |
255 | 264 | | |
256 | 265 | | |
257 | | - | |
| 266 | + | |
258 | 267 | | |
259 | 268 | | |
260 | 269 | | |
| |||
274 | 283 | | |
275 | 284 | | |
276 | 285 | | |
| 286 | + | |
277 | 287 | | |
278 | 288 | | |
279 | | - | |
| 289 | + | |
280 | 290 | | |
281 | 291 | | |
282 | 292 | | |
| |||
304 | 314 | | |
305 | 315 | | |
306 | 316 | | |
307 | | - | |
| 317 | + | |
308 | 318 | | |
309 | 319 | | |
310 | 320 | | |
311 | 321 | | |
312 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
313 | 385 | | |
314 | 386 | | |
315 | 387 | | |
| |||
323 | 395 | | |
324 | 396 | | |
325 | 397 | | |
326 | | - | |
| 398 | + | |
327 | 399 | | |
328 | 400 | | |
329 | 401 | | |
| |||
347 | 419 | | |
348 | 420 | | |
349 | 421 | | |
| 422 | + | |
| 423 | + | |
350 | 424 | | |
351 | 425 | | |
352 | 426 | | |
| |||
0 commit comments