Use Riddle API v2

Created on 14 August 2020, over 4 years ago
Updated 23 February 2023, almost 2 years ago

Problem/Motivation

Since November 2019 the old API has been deprecated. See: https://www.riddle.com/docs/api/riddles/get-riddle-embed-code/
It is now recommended to use https://www.riddle.com/docs/api/api-v2-documentation/
The authentication method has been altered so we need 2 fields in the settings form. One for the token and one for the api key.

Also, the import Riddles method in the media entities overview didn't show the local action used an incorrect route.

Finally, the readme still mentions a custom paragraph type, even though in version 3 there is no longer a paragraphs submodule, just a media submodule.

Proposed resolution

I've updated the RiddleFeedService to use the new v2 riddle api. Including the new authentication method.

Remaining tasks

Create a hook_update_N() implementation to update the old 'token' setting to the new 'api_token' setting. And force update of the api_url within the immutable config storage.

User interface changes

Enabled the "import riddles" local action button on /admin/content/media

Data model changes

The riddle_marketplace.settings config now has a a) new api_url value, b) the token property has been renamed api_token, and c) there is a new property called api_key.

Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

🇳🇱Netherlands basvredeling Amsterdam

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany osopolar 🇩🇪 GER 🌐

    Thank you dejan0, your patch from #12 worked for me also to be able to access text format pages like admin/config/content/formats/manage/basic_html

  • Status changed to Needs work over 1 year ago
  • 🇩🇪Germany osopolar 🇩🇪 GER 🌐

    I found that updating after patching the module did not update the riddle_marketplace.api_url

    Documentation for hook_post_update_NAME says:

    Drupal also ensures to not execute the same hook_post_update_NAME() function twice.

    Therefore I assume a new hook_post_update_NAME function needs to be added to riddle_marketplace.post_update.php and implement the changes.

    As workaround I just edited the exported riddle_marketplace.settings.yml file and imported it again.

  • 🇦🇹Austria a.milkovsky UTC +2

    Update: Riddle API has a new version now - version 3. Only 1 token is needed now.
    https://www.riddle.com/help/api/

    Authentication

    To access the API you need an API key. You can find or create new API keys on the API keys page in the Riddle creator. Once you have found or created an API key, you can use it to authenticate against the API.

    Example Request:

    URL: https://www.riddle.com/creator/api/v3/riddle/list
    HTTP method: POST
    Headers:
    {
    Authorization: "Bearer [your API key]"
    }

  • 🇦🇹Austria a.milkovsky UTC +2

    This patch solves next issues:

    1. The #12 works fine, but it checks only the first 50 riddles in a paged response. I extended the RiddleFeedService to fetch Riddles from all the pages.
    2. I addressed #14
  • Status changed to Needs review 5 days ago
  • 🇦🇹Austria a.milkovsky UTC +2

    Hi I am a new module co-maintainer of Riddle Market place.

    As mentioned previously, Riddle.com has released a new API v3.
    For the integration with the new API version a new 4.x branch was started in this project.

    It looks like both the Riddle API v2 and API v1 are obsolete now, thus I so not plan to maintain the 8.x-3.x branch actively.
    Please consider using the new 4.x branch for both the latest API v3 integration and Drupal 10 support.

    Existing patches can still be applied for the v2 integration. Feel free to review the changes in #16.

Production build 0.71.5 2024