You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been dropped in a little at the deep end here, and am new to just about everything involved except for PHP, so please excuse me if I'm being daft. I'm trying to authenticate against my own account, I have no need to do so for other users' accounts, so am attempting to use setToken with the oauth token and secret provided under SmugMug's web interface (Settings -> Privacy -> Authorized Services -> Token) rather than going through the token request process. Is there some reason that should't work?
My code is extremely simple and initially looked like this:
<?phpini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// This file is generated by Composerrequire_once'vendor/autoload.php';
// Optional, but definitely nice to have, options$options = [
'AppName' => 'My Test/1.0 (https://www.example.org)',
];
$client = new phpSmug\Client('MY API KEY', $options);
print "<br><b>Setting Token:</b><br>";
$client->setToken('MY OAUTH TOKEN', 'MY OAUTH SECRET');
# THIS IS THE POINT WHERE IT BREAKS TO START WITH
print "<br><b>Getting list of repositories:</b><br>";
$repositories = $client->get('user/MYUSERNAME!albums');
# THIS IS THE POINT WHERE IT BREAKS WITH SECRET IN OPTIONSprint_r($repositories);
...
That fails at the first point shown by my comments above, and gives me a:
"Fatal error: Uncaught exception 'phpSmug\Exception\InvalidArgumentException' with message 'An OAuthSecret is required for all SmugMug OAuth interactions.' in /var/www/other/smug/vendor/lildude/phpsmug/lib/phpSmug/Client.php:389 Stack trace: #0 /var/www/other/smug/index.php(19): phpSmug\Client->setToken('MY OAUTH TOKEN...', 'MY OAUTH SECRET...') #1 {main} thrown in /var/www/other/smug/vendor/lildude/phpsmug/lib/phpSmug/Client.php on line 389"
If I add 'OAuthSecret' => 'MY OAUTH SECRET' to options, the client seems to be instantiated OK, but it breaks at the second point shown by my comments, with::
"Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: GET https://api.smugmug.com/api/v2/user/MYUSERNAME!albums resulted in a 401 Unauthorized response: {"Code":401,"Message":"oauth_problem=signature_invalid&debug_sbs=GET&https%3A%2F%2Fapi.smugmug.com%2Fapi%2Fv2%2Fuser%2Fi (truncated...) ' in /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/other/smug/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/other/smug/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/other/smug/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleH in /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113"
I've tried to follow the phpsmug and smugmug API documentation with a dollop of common sense, but have clearly gone astray. Any help or hints would be appreciated.
Thanks,
Adrian
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had activity in 14 days. It will be closed in 2 days if no further activity occurs. Thank you for your contributions.
I've been dropped in a little at the deep end here, and am new to just about everything involved except for PHP, so please excuse me if I'm being daft. I'm trying to authenticate against my own account, I have no need to do so for other users' accounts, so am attempting to use setToken with the oauth token and secret provided under SmugMug's web interface (Settings -> Privacy -> Authorized Services -> Token) rather than going through the token request process. Is there some reason that should't work?
My code is extremely simple and initially looked like this:
That fails at the first point shown by my comments above, and gives me a:
"Fatal error: Uncaught exception 'phpSmug\Exception\InvalidArgumentException' with message 'An OAuthSecret is required for all SmugMug OAuth interactions.' in /var/www/other/smug/vendor/lildude/phpsmug/lib/phpSmug/Client.php:389 Stack trace: #0 /var/www/other/smug/index.php(19): phpSmug\Client->setToken('MY OAUTH TOKEN...', 'MY OAUTH SECRET...') #1 {main} thrown in /var/www/other/smug/vendor/lildude/phpsmug/lib/phpSmug/Client.php on line 389"
If I add 'OAuthSecret' => 'MY OAUTH SECRET' to options, the client seems to be instantiated OK, but it breaks at the second point shown by my comments, with::
"Fatal error: Uncaught exception 'GuzzleHttp\Exception\ClientException' with message 'Client error:
GET https://api.smugmug.com/api/v2/user/MYUSERNAME!albums
resulted in a401 Unauthorized
response: {"Code":401,"Message":"oauth_problem=signature_invalid&debug_sbs=GET&https%3A%2F%2Fapi.smugmug.com%2Fapi%2Fv2%2Fuser%2Fi (truncated...) ' in /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Middleware.php(66): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /var/www/other/smug/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/other/smug/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array) #3 /var/www/other/smug/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleH in /var/www/other/smug/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113"I've tried to follow the phpsmug and smugmug API documentation with a dollop of common sense, but have clearly gone astray. Any help or hints would be appreciated.
Thanks,
Adrian
The text was updated successfully, but these errors were encountered: