Я использую Yahoo Fantasy Sports API с OAuth 1 и PHP уже много лет без проблем. В течение последних нескольких недель авторизация пользователя не удалась.
По сути, после получения того, что в противном случае является токеном от Yahoo, когда мы собираем информацию из API, мы получаем 401 ошибку в ответ. Что очень странно в том, что мы случайно получаем 401 ошибку или данные в ответ.
Я даже попробовал пример PHP-скрипта, предоставленного Yahoo — та же ошибка. Вот краткий снимок вызовов CLI с использованием сценария — два вызова в быстрой последовательности, первый возвращает 401, а второй возвращает данные:
root@dednew:/var/www/fhg# /opt/php-5.6/bin/php tester.php
Got access token information!
Token: A=GMj2OgnmgiODpfvH9HkbcQr9Phz2qNYOhTLbEfdNMGz7NGJ6c9KDNkxndObLi8vD.USTPkaTvdPrnoIkZo7QYI277fOs1fJjuOCVapOm16qoZUcP7BFkgbC9ay1iLdF7__BHNiVMS75Jtr.p6249F02Z2Ld2dE8KkUNxDtwF8tSi5UBCL1R1xd0tzusw0cITPBJGd5_wMwf5E3BVEr1ZmoQbYgGBwMpcQvIPFbmw7PaByQPvhZ7OhriYVe1sFDk_paGki4ThaC.rua9QoUx25Txpgiksp3PqUfrq4Mnp3fqJvG4ZZbMD4VBRnQaSyibeJR5QiaB1sk088.YW7SdPRLXU_2I78A_jnYro8AMZD_DRAatU9Va6WL1gdBcVccO8WHu4DQwSFESfadl8qFrEEPA2hyfzlPDdp2BFoyFORjOvAqI_O5agLM_4jl1tJPXSHAYjeLHpBgazdP23Qcuj4doG_JYBTCQW_BKSuMKLUd15sLy3J4GcqiPiE7jQ7JGrKxjt417sRcjVL0ziksatzvzeFyXNyrYBE0YohFqYjd_4_hSUMX9SgnVcXEmhPxO6zlISpcj0OVpSqQyZ752SuZEazzBVtqSGFgz0IWd8.fV.g5EmXr.FLh.5fc8ShkHM5Zxk1HfowIZtzuAfco32_SLpe3047gq0lt.nu4kY_L57CnsPVopSsol6F.nNiPAM9jZLrDPZP1RprgaDlbKdOPukLw5SGzEHlOArXcfIFL37n4vVg53u9jK7Nv1krw1kzgwWE6meGVUdc7JRcdTtJf6FB2T7.NqFmYkL
Secret: 32cbad8c8b5adbb441458615d5db7f30d3128749
Session Handle: AMW.zllcRE9V.ztlfxWt0TkfIMCDVue0jurjx1FlIEux4l71mkRv
Error: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
Error Code: 401
Response: <?xml version="1.0" encoding="UTF-8"?>
<error xml:lang="en-us" yahoo:uri="http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=nfl/teams?oauth_consumer_key=dj0yJmk9cE0yWnZzRVFEbjhFJmQ9WVdrOWNuY3pOVWczTXpJbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1hYw--&amp;oauth_signature_method=HMAC-SHA1&amp;oauth_nonce=87474055259cedbfd522a68.21090926&amp;oauth_timestamp=1506728957&amp;oauth_version=1.0&amp;oauth_token=A%3DGMj2OgnmgiODpfvH9HkbcQr9Phz2qNYOhTLbEfdNMGz7NGJ6c9KDNkxndObLi8vD.USTPkaTvdPrnoIkZo7QYI277fOs1fJjuOCVapOm16qoZUcP7BFkgbC9ay1iLdF7__BHNiVMS75Jtr.p6249F02Z2Ld2dE8KkUNxDtwF8tSi5UBCL1R1xd0tzusw0cITPBJGd5_wMwf5E3BVEr1ZmoQbYgGBwMpcQvIPFbmw7PaByQPvhZ7OhriYVe1sFDk_paGki4ThaC.rua9QoUx25Txpgiksp3PqUfrq4Mnp3fqJvG4ZZbMD4VBRnQaSyibeJR5QiaB1sk088.YW7SdPRLXU_2I78A_jnYro8AMZD_DRAatU9Va6WL1gdBcVccO8WHu4DQwSFESfadl8qFrEEPA2hyfzlPDdp2BFoyFORjOvAqI_O5agLM_4jl1tJPXSHAYjeLHpBgazdP23Qcuj4doG_JYBTCQW_BKSuMKLUd15sLy3J4GcqiPiE7jQ7JGrKxjt417sRcjVL0ziksatzvzeFyXNyrYBE0YohFqYjd_4_hSUMX9SgnVcXEmhPxO6zlISpcj0OVpSqQyZ752SuZEazzBVtqSGFgz0IWd8.fV.g5EmXr.FLh.5fc8ShkHM5Zxk1HfowIZtzuAfco32_SLpe3047gq0lt.nu4kY_L57CnsPVopSsol6F.nNiPAM9jZLrDPZP1RprgaDlbKdOPukLw5SGzEHlOArXcfIFL37n4vVg53u9jK7Nv1krw1kzgwWE6meGVUdc7JRcdTtJf6FB2T7.NqFmYkL&amp;oauth_signature=3N%2Fv7E94sSz7u1T%2FnZw7LSL%2FqH8%3D" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns="http://www.yahooapis.com/v1/base.rng">
<description>Invalid cookie, please log in again.</description>
<detail/>
</error>
Array
(
[oauth_token] => A=UOj1pgHd.AMPSWtSpTpOV7H26tlA5pBx6JFxqZ5t1XDH.Tbat9FvZasADKWuXm9oKKr_vaaWZBRS2RyP4eAmeOEBWFM3HSg1VHrtr8Z9XDhfr_n6b5ujgyFt_Grw8pf5pbfC0x4YelJCH0HDOdmg3tatVsDBLdc79WkQnJ6.4NS2IXBskwpeVGxRpKiH3EYSJ1z_5L6hZQtsegK1jgqsyzezvf6BgJjeOUO84mI175VOX5KY4ht2WE.qzOK21vvxilWlKOT2lTvJdYNH.47B2y.XXqw6WNwfqoIrChVkcr4l_oqE_gzeHlsox6Z1gtl1WgDGeLWqS9iJZqn0AWvbgOk38FVTFkJcYprPthOQBtyLZyom04NVIStnuZ.xc7EEZVKHg88_lHj28uyrbF8ZPD4f3bI0A8nHX6f9Z3ZhgxbSLyG44BiTjAp..Q3qXB45I4gvHqlEferLBwG6T.NHV48XDk3cbf3y7SbtjEaDwr6ityMkp2xMUhqHMJQ4DfxmuRejwadZ0FeK8sqfkZSR2nnQiGN3t61Sla.tf3fFHusbHVEj2Mp2Mk85FL2APWWOtNA6QRSMou38FX5x2YnWYpTkcC9QXxFniWY.eU4lupyVT.KX4hvsc2xBxhbD9zfnGMef1Yg_7w4rlMUbrpAw9JAKtDAHFJS6VvY.FnRV3SiDd3Ck8dEx0BGLSmxE052qeRGjnxTv_0G4.Kj.4vFY4ztBDtlKZTLUvEbPZJKDU0CXSTfOEo1C99e3R19SS8Eh_KVToP3Z81_7QWrLzCSfJqXFQUdQLfgUzCJV
[oauth_token_secret] => 6fd5d695882ef63b18bf786be3c8463cdea33e7f
[oauth_expires_in] => 3600
[oauth_session_handle] => AMW.zllcRE9V.ztlfxWt0TkfIMCDVue0jurjx1FlIEux4l71mkRv
[oauth_authorization_expires_in] => 640754690
[xoauth_yahoo_guid] => WI3IFMZVEK4K7CINH6WJSKPU7A
)
Was able to refresh access token:
Token: A=UOj1pgHd.AMPSWtSpTpOV7H26tlA5pBx6JFxqZ5t1XDH.Tbat9FvZasADKWuXm9oKKr_vaaWZBRS2RyP4eAmeOEBWFM3HSg1VHrtr8Z9XDhfr_n6b5ujgyFt_Grw8pf5pbfC0x4YelJCH0HDOdmg3tatVsDBLdc79WkQnJ6.4NS2IXBskwpeVGxRpKiH3EYSJ1z_5L6hZQtsegK1jgqsyzezvf6BgJjeOUO84mI175VOX5KY4ht2WE.qzOK21vvxilWlKOT2lTvJdYNH.47B2y.XXqw6WNwfqoIrChVkcr4l_oqE_gzeHlsox6Z1gtl1WgDGeLWqS9iJZqn0AWvbgOk38FVTFkJcYprPthOQBtyLZyom04NVIStnuZ.xc7EEZVKHg88_lHj28uyrbF8ZPD4f3bI0A8nHX6f9Z3ZhgxbSLyG44BiTjAp..Q3qXB45I4gvHqlEferLBwG6T.NHV48XDk3cbf3y7SbtjEaDwr6ityMkp2xMUhqHMJQ4DfxmuRejwadZ0FeK8sqfkZSR2nnQiGN3t61Sla.tf3fFHusbHVEj2Mp2Mk85FL2APWWOtNA6QRSMou38FX5x2YnWYpTkcC9QXxFniWY.eU4lupyVT.KX4hvsc2xBxhbD9zfnGMef1Yg_7w4rlMUbrpAw9JAKtDAHFJS6VvY.FnRV3SiDd3Ck8dEx0BGLSmxE052qeRGjnxTv_0G4.Kj.4vFY4ztBDtlKZTLUvEbPZJKDU0CXSTfOEo1C99e3R19SS8Eh_KVToP3Z81_7QWrLzCSfJqXFQUdQLfgUzCJV
Secret: 6fd5d695882ef63b18bf786be3c8463cdea33e7f
Session Handle: AMW.zllcRE9V.ztlfxWt0TkfIMCDVue0jurjx1FlIEux4l71mkRv
Error: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
Error Code: 401
Response: <?xml version="1.0" encoding="UTF-8"?>
<error xml:lang="en-us" yahoo:uri="http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=nfl/teams?oauth_consumer_key=dj0yJmk9cE0yWnZzRVFEbjhFJmQ9WVdrOWNuY3pOVWczTXpJbWNHbzlNQS0tJnM9Y29uc3VtZXJzZWNyZXQmeD1hYw--&amp;oauth_signature_method=HMAC-SHA1&amp;oauth_nonce=209070770059cedbfd9fd1d0.76088688&amp;oauth_timestamp=1506728957&amp;oauth_version=1.0&amp;oauth_token=A%3DUOj1pgHd.AMPSWtSpTpOV7H26tlA5pBx6JFxqZ5t1XDH.Tbat9FvZasADKWuXm9oKKr_vaaWZBRS2RyP4eAmeOEBWFM3HSg1VHrtr8Z9XDhfr_n6b5ujgyFt_Grw8pf5pbfC0x4YelJCH0HDOdmg3tatVsDBLdc79WkQnJ6.4NS2IXBskwpeVGxRpKiH3EYSJ1z_5L6hZQtsegK1jgqsyzezvf6BgJjeOUO84mI175VOX5KY4ht2WE.qzOK21vvxilWlKOT2lTvJdYNH.47B2y.XXqw6WNwfqoIrChVkcr4l_oqE_gzeHlsox6Z1gtl1WgDGeLWqS9iJZqn0AWvbgOk38FVTFkJcYprPthOQBtyLZyom04NVIStnuZ.xc7EEZVKHg88_lHj28uyrbF8ZPD4f3bI0A8nHX6f9Z3ZhgxbSLyG44BiTjAp..Q3qXB45I4gvHqlEferLBwG6T.NHV48XDk3cbf3y7SbtjEaDwr6ityMkp2xMUhqHMJQ4DfxmuRejwadZ0FeK8sqfkZSR2nnQiGN3t61Sla.tf3fFHusbHVEj2Mp2Mk85FL2APWWOtNA6QRSMou38FX5x2YnWYpTkcC9QXxFniWY.eU4lupyVT.KX4hvsc2xBxhbD9zfnGMef1Yg_7w4rlMUbrpAw9JAKtDAHFJS6VvY.FnRV3SiDd3Ck8dEx0BGLSmxE052qeRGjnxTv_0G4.Kj.4vFY4ztBDtlKZTLUvEbPZJKDU0CXSTfOEo1C99e3R19SS8Eh_KVToP3Z81_7QWrLzCSfJqXFQUdQLfgUzCJV&amp;oauth_signature=hU0ugY1YZbcLICWBjd99HVlh7CA%3D" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns="http://www.yahooapis.com/v1/base.rng">
<description>Invalid cookie, please log in again.</description>
<detail/>
</error>
Looks like we need to store access token data! Doing that now.root@dednew:/var/www/fhg# /opt/php-5.6/bin/php tester.php
Got access token information!
Token: A=UOj1pgHd.AMPSWtSpTpOV7H26tlA5pBx6JFxqZ5t1XDH.Tbat9FvZasADKWuXm9oKKr_vaaWZBRS2RyP4eAmeOEBWFM3HSg1VHrtr8Z9XDhfr_n6b5ujgyFt_Grw8pf5pbfC0x4YelJCH0HDOdmg3tatVsDBLdc79WkQnJ6.4NS2IXBskwpeVGxRpKiH3EYSJ1z_5L6hZQtsegK1jgqsyzezvf6BgJjeOUO84mI175VOX5KY4ht2WE.qzOK21vvxilWlKOT2lTvJdYNH.47B2y.XXqw6WNwfqoIrChVkcr4l_oqE_gzeHlsox6Z1gtl1WgDGeLWqS9iJZqn0AWvbgOk38FVTFkJcYprPthOQBtyLZyom04NVIStnuZ.xc7EEZVKHg88_lHj28uyrbF8ZPD4f3bI0A8nHX6f9Z3ZhgxbSLyG44BiTjAp..Q3qXB45I4gvHqlEferLBwG6T.NHV48XDk3cbf3y7SbtjEaDwr6ityMkp2xMUhqHMJQ4DfxmuRejwadZ0FeK8sqfkZSR2nnQiGN3t61Sla.tf3fFHusbHVEj2Mp2Mk85FL2APWWOtNA6QRSMou38FX5x2YnWYpTkcC9QXxFniWY.eU4lupyVT.KX4hvsc2xBxhbD9zfnGMef1Yg_7w4rlMUbrpAw9JAKtDAHFJS6VvY.FnRV3SiDd3Ck8dEx0BGLSmxE052qeRGjnxTv_0G4.Kj.4vFY4ztBDtlKZTLUvEbPZJKDU0CXSTfOEo1C99e3R19SS8Eh_KVToP3Z81_7QWrLzCSfJqXFQUdQLfgUzCJV
Secret: 6fd5d695882ef63b18bf786be3c8463cdea33e7f
Session Handle: AMW.zllcRE9V.ztlfxWt0TkfIMCDVue0jurjx1FlIEux4l71mkRv
Got data from API:
<?xml version="1.0" encoding="UTF-8"?>
<fantasy_content xml:lang="en-US" yahoo:uri="http://fantasysports.yahooapis.com/fantasy/v2/users;use_login=1/games;game_keys=nfl/teams" time="39.669990539551ms" copyright="Data provided by Yahoo! and STATS, LLC" refresh_rate="60" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xmlns="http://fantasysports.yahooapis.com/fantasy/v2/base.rng">
<users count="1">
<user>
<guid>WI3IFMZVEK4K7CINH6WJSKPU7A</guid>
<games count="1">
<game>
<game_key>371</game_key>
<game_id>371</game_id>
<name>Football</name>
<code>nfl</code>
<type>full</type>
<url>https://football.fantasysports.yahoo.com/f1</url>
<season>2017</season>
<is_registration_over>0</is_registration_over>
<is_game_over>0</is_game_over>
<is_offseason>0</is_offseason>
<teams/>
</game>
</games>
</user>
</users>
</fantasy_content>
<!-- fanos916.sports.bf1.yahoo.com Fri Sep 29 23:49:19 UTC 2017 -->Successful!
Я в недоумении относительно того, что происходит, и мне интересно, если это проблема Yahoo.
Я только начал с fantasysports.yahooapis.com. Я тоже с этим борюсь, хотел бы поделиться мыслями. Может быть, у нас есть код, который поможет друг другу.
Других решений пока нет …