PHP Oauth gets 401 on PHP 7.3, ok on PHP 7.2 and earlier

与世无争的帅哥 提交于 2020-07-07 11:28:31

问题


I'm trying to use PHP's Oauth module to interact with Etsy's API.

Following Etsy's docs, I have

<?php

if (!extension_loaded('oauth')) {
   throw new Exception('Oauth not loaded.');
}

$oauth = new OAuth("foobar-key", "foobar-secret");
$req_token = $oauth->getRequestToken(
    "https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20listings_r",
    "oob",
    "GET"
);

This works fine when run with php7.2:

php7.2 etsy-oauth.php
...
OK

When the same is run with php7.3, though, I get a 401:

php7.3 etsy-oauth.php
...
PHP Fatal error:  Uncaught OAuthException: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
oauth_problem=signature_invalid

OAuth is definitely installed for both PHP 7.2 and PHP 7.3, as confirmed by the extension_loaded above, and by:

php7.2 -m | grep OAuth
OAuth
php7.3 -m | grep OAuth
OAuth

I haven't been able to find any documented difference in how this same call should be made in PHP 7.3 vs PHP 7.2.

How should this Oauth call be made correctly in PHP 7.3?


回答1:


I had same problem in php7.3. Try to install OAuth 2.0.5. It work for me



来源:https://stackoverflow.com/questions/58890514/php-oauth-gets-401-on-php-7-3-ok-on-php-7-2-and-earlier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!