Problem/Motivation

Creation media entity failed due to validation of field Instagram URL (field_media_oembed_instagram_1) with message "The provided URL does not represent a valid oEmbed resource"

Steps to reproduce

1. Download and install module using composer
2. Set "App id" and "App secret" in /admin/config/media/instagram-settings
3. Add new media type /admin/structure/media/add

  • Media source = Instagram
  • Field with source information = Create

4. Add new entity instance /media/add/{new name}

Results:
1 error has been found: Instagram URL
The provided URL does not represent a valid oEmbed resource.

Direct API request working well

https://graph.facebook.com/v9.0/instagram_oembed?url=https://www.instagram.com/p/CAYbO7MANtt/&access_token={app id}|{app secret}
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dimonuga created an issue. See original summary.

dimonuga’s picture

Issue summary: View changes
superfluousapostrophe’s picture

I'm getting the same error. Looking in the logs shows this message:

Client error: `GET https://api.instagram.com/oembed?url=https%3A//www.instagram.com/p/CEpOM...` resulted in a `400 Bad Request` response:\nThis endpoint is deprecated. Please read https

bkosborne’s picture

Re: #3, that sounds like you're on the old version of the module. You need to upgrade to the latest version and set up a Facebook App and input the App ID and Secret in config.

For the original post, it may be that your Facebook App does not have the Instagram OEmbed product added. You also need to initiate the App Review process, though it's a simple process that happens automatically. This is what happened to me and I had the same generic error. The media entity will fail validation if it cannot download the oembed data. I used xdebug to get the HTTP response message from the oEmbed request.

This, I suspect, is really a documentation issue.

joewhitsitt made their first commit to this issue’s fork.

joewhitsitt’s picture

We were reviewing 3.0.4 in preparation for D9 and noticed this issue as well for 3.0.4 and our existing version. We are using the Facebook App for media_entity_facebook and don't have any issues with the app status/credentials. This appears to grab the deprecated https://api.instagram.com/oembed endpoint which is now second in the endpoints array. This removes that as GraphAPI is now first in endpoints.

joewhitsitt’s picture

Version: 3.0.4 » 3.x-dev
Status: Active » Needs review
Jill L’s picture

Having the exact same problem as joewhitsitt: the order of the endpoints has changed, and the code was using the old oembed one.

Uploading a patch of the diff, to have a static version for use in Composer projects.

useernamee’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +oembed, +media oembed

I've encountered the same issue with media_entity_instagram version 3.0.4 and this patch solves our issue. Moving into RTBC.

It might be worth adding that current code in media_entity_instagram_oembed_resource_url_alter()

  if (count($endpoints) > 1) {
    $endpoint = $endpoints[1];
  }

is very susceptible for bugs. It would be better to check endpoints with a regex or sth if they match a condition instead of just hoping that sort order will stay the same.

acbramley’s picture

#9 fixed the same issue for me, thanks! I also agree with #10, wondering if there should be some testing around this?

OCTOGONE.dev’s picture

I am unable to get this working this on Drupal 8.9.

Can we have a status on this. Are you planning to release a new version that correct this problem? Date?

Thank you.

chr.fritsch’s picture

Since https://github.com/iamcal/oembed/pull/515 was merged, this shouldn't be an issue anymore.

OCTOGONE.dev’s picture

@ chr.fritsch

After patching with #9 and testing the last version of oembed module, it does not resolve this problem, i still have the message "The provided URL does not represent a valid oEmbed resource."

Instagram URL tested : https://www.instagram.com/p/CJUJXSgJgDi.

Thus is suppose this is not related with the oembed module, but with this instagram module

rockaholiciam’s picture

I am getting the same message but I thought it was because instagram doesn't allow linking to another accounts images images anymore. Can you link to any instagram post or only those posted by your own account?

amstercad’s picture

Using the latest Drupal 9.2.6, patch #9 doesn't seem to do anything, and I also see the error message, "The provided URL does not represent a valid oEmbed resource.".

osopolar’s picture

FWIW, under app-review > permissions and features you may read the following note:

Introducing New Data Access Levels
Development Mode and Live Mode have been replaced with new data access levels, more flexibility and streamline integration when building and using your business app. Standard Access is granted automatically and permits access to data owned by your business. Advanced Access must be requested through App Review to access data owned by people outside your business. If you don't need any level of access to a permission or feature, you can remove it and it will be listed as No Access.

So you probably need to request advanced access for "Oembed Read". I will leave a comment here if it worked (currently the request is pending).

szeidler’s picture

The patch in #9 seems not to resolve the issue anymore. I also suspect that it's related to the new access levels described in #17. Or will the patch be required and helping if you want to embed instagram content from your own account?

Have you succeeded the review phase? Has it resolved the problem?

joewhitsitt’s picture

I'll chime into say, my org is no longer using this MR/patch because of #13. My org had to go through a review process for oembed read. We haven't had issues since.

nivethitha’s picture

yes. "Oembed Read" access approved. now working fine with instagram post on site. we need to follow few steps for getting it,

1. login on https://developers.facebook.com/
2. create app using this: https://developers.facebook.com/docs/development/create-an-app/
3. After app creation, request for ombed read and submit
4. give valid info about app and get permission and submit for app review
5. within 5days will get the access of it
6. use your app id and secret on instagram setting config then normally we can use instagram feed in content

a.milkovsky’s picture

I guess this issue can be closed as outdated, as there was no activity for 1 year. Also the patched lines do not exist anymore.

chr.fritsch’s picture

Status: Reviewed & tested by the community » Closed (outdated)