daviddesberg / PHPoAuthLib

PHP 5.3+ oAuth 1/2 Client Library
Other
1.09k stars 456 forks source link

Carrying over refresh token #569

Open jacobb84 opened 3 years ago

jacobb84 commented 3 years ago

This builds upon the work done in PR 381. That ticket is on hold because it was perceived to be a Google specific issue, but I think the issue is broader then that. I noticed the same issue on SalesForce and Issue #26 reports the same issue for Facebook. I took a look at the oAuth specification and I think I see where the disconnect is. Take a look at the diagram in this section on authorization flow: https://tools.ietf.org/html/rfc6749#section-1.5

G and H in the diagram document the refresh-token flow and according to H the server may optionally return a new refresh token as part of that request. For environments that don't expire the refresh token, it is never returned. I think since the RFC for it says it's optional we should account for it at the abstract service layer.

This takes the approach in PR 381 but with an added check to be sure the refresh token is absent before it carries it over, to ensure it doesn't break flows that do decide to return a new refresh token.

jacobb84 commented 3 years ago

The test failure seems unrelated to this change.

tezrik commented 3 years ago

Please add tests for your functionality