From b8ee31a0ce93c4a67c0f2c18a0f56d27b83b46ed Mon Sep 17 00:00:00 2001 From: Bas Brands Date: Wed, 10 Jun 2020 15:08:41 +0200 Subject: [PATCH] MDL-69006 repository_flickr: flickr authentication fails - Flickr does not like useragents including the word "Bot" --- lib/flickrclient.php | 4 ++++ lib/oauthlib.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/flickrclient.php b/lib/flickrclient.php index 7d375511048..de57c328b83 100644 --- a/lib/flickrclient.php +++ b/lib/flickrclient.php @@ -60,12 +60,16 @@ class flickr_client extends oauth_helper { * @param moodle_url|string $callbackurl */ public function __construct($consumerkey, $consumersecret, $callbackurl = '') { + global $CFG; + $version = moodle_major_version(); + $useragent = "MoodleSite/$version (+{$CFG->wwwroot})"; parent::__construct([ 'api_root' => self::OAUTH_ROOT, 'oauth_consumer_key' => $consumerkey, 'oauth_consumer_secret' => $consumersecret, 'oauth_callback' => $callbackurl, + 'http_options' => ['CURLOPT_USERAGENT' => $useragent] ]); } diff --git a/lib/oauthlib.php b/lib/oauthlib.php index a20d2d971c5..30c192f97d2 100644 --- a/lib/oauthlib.php +++ b/lib/oauthlib.php @@ -108,7 +108,11 @@ class oauth_helper { $this->access_token_secret = $args['access_token_secret']; } $this->http = new curl(array('debug'=>false)); - $this->http_options = array(); + if (!empty($args['http_options'])) { + $this->http_options = $args['http_options']; + } else { + $this->http_options = array(); + } } /** -- 2.43.0