Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject ready promise on 403 #264

Merged
merged 3 commits into from
Jun 13, 2018
Merged

Reject ready promise on 403 #264

merged 3 commits into from
Jun 13, 2018

Conversation

tenacex
Copy link
Contributor

@tenacex tenacex commented Jun 1, 2018

This PR gives users the ability to properly detect errors on player instantiation. We detect errors as follows:

var player = new Vimeo.Player('made-in-ny', options); player.ready().catch((error) => { console.log('ERROR', error); });

Before this change, a 403 (privacy settings error) wouldn't be caught. Now, we throw the error to allow devs to give their own visual feedback. This currently is using a CI link, which will be updated to production before being merged.

Fixes #165

@wesbos
Copy link

wesbos commented Jun 1, 2018

@tenacex can you commit a compiled dist/player.js so I can test it?

@tenacex
Copy link
Contributor Author

tenacex commented Jun 1, 2018

@wesbos previously we have not committed dist fils. Please run npm run build to create the dist files!

@wesbos
Copy link

wesbos commented Jun 1, 2018

Ah! Easy okay thanks - will try it

@wesbos
Copy link

wesbos commented Jun 1, 2018

I'm not sure if I have access to https://api-2489.ci.vimeows.com/api/oembed.json?url=https%3A%2F%2Fvimeo.com%2F184581834&domain=localhost&id=184581834&width=640&loop=true

It's timing out after about 72 seconds. Good news is that the .catch is catching this network error so I'd say it's working :D

thanks for this!

@tenacex
Copy link
Contributor Author

tenacex commented Jun 1, 2018

@wesbos ah yes sorry I forgot you would have to be within our VPN. API team told me it would be released this morning so I will hook into it as soon as that happens.

src/lib/embed.js Outdated

// Check api response for 403 on oembed
if (json['domain_status_code'] === 403) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace.

src/lib/embed.js Outdated
@@ -52,13 +52,13 @@ export function getOEmbedParameters(element, defaults = {}) {
* @param {Object} [params] Parameters to pass to oEmbed.
* @return {Promise}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update doc block

@luwes
Copy link
Contributor

luwes commented Jun 11, 2018

@dylandove does this also take in account iframe setups? I think the oEmbed data is only used when setting up a div element with the Vimeo.Player constructor or no?

@tenacex
Copy link
Contributor Author

tenacex commented Jun 11, 2018

@luwes I am not entirely sure what you mean? In the player.js codebase we get back an iframe element and embed it directly into the dom. I don't think we ever refer to a specific div in this setup. Does that answer your question?

Copy link
Contributor

@luwes luwes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tenacex tenacex merged commit cd9bccd into master Jun 13, 2018
@simplystuart
Copy link

@tenacex Not sure what's going on but videos that were previously embedding fine on my end are now spitting out the new 403 errors instead of loading. The videos I'm referencing have domain specific embed/privacy settings.

I fixed by rolling back to 2.6.1 (I was previously using the CDN). This was on a live server so unfortunately I can't do much digging at the moment. Could it be something with this line?

https://github.com/vimeo/player.js/blob/master/src/lib/embed.js#L87

@tenacex
Copy link
Contributor Author

tenacex commented Jun 14, 2018

@simplystuart could you please send me the video ID's and I will investigate? Thanks

@simplystuart
Copy link

@tenacex Thanks! Here's one: 152183192

@tenacex
Copy link
Contributor Author

tenacex commented Jun 14, 2018

@simplystuart sorry also could you send me an example domain you are attempting to embed on?

@simplystuart
Copy link

@tenacex classicalacademicpress.com

@tenacex
Copy link
Contributor Author

tenacex commented Jun 14, 2018

Hey @simplystuart could you do me a favor and do some debugging on this? Since this error is dependent on behavior on your site, I can't do it just by myself.

Could you add a console.log(json) here: https://github.com/vimeo/player.js/blob/master/src/lib/embed.js#L111.

Also could you add a console.log(url) here: https://github.com/vimeo/player.js/blob/master/src/lib/embed.js#L88

If you get back to me with those logs I think that will lead me in the right direction. Thanks!

@simplystuart
Copy link

@tenacex sure:

account_type : "pro" author_name : "Classical Academic Press" author_url : "https://vimeo.com/user4527911" description : "" domain_status_code : 403 duration : 543 height : 540 html : "<iframe src="https://player.vimeo.com/video/152183192?app_id=122963" width="540" height="540" frameborder="0" title="01 SSS1" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>" is_plus : "0" provider_name : "Vimeo" provider_url : "https://vimeo.com/" thumbnail_height : 166 thumbnail_url : "https://i.vimeocdn.com/video/552106853_295x166.jpg" thumbnail_url_with_play_button : "https://i.vimeocdn.com/filter/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F552106853_295x166.jpg&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png" thumbnail_width : 295 title : "01 SSS1" type : "video" upload_date : "2016-01-18 12:41:04" uri : "/videos/152183192" version : "1.0" video_id : 152183192 width : 540

and:

https://vimeo.com/api/oembed.json?url=https%3A%2F%2Fvimeo.com%2F152183192&domain=classicalacademicpress.com

Clarification from earlier... the first video above loads fine, but then when I go to switch videos with {player}.loadVideo(152183739), then I get Error: “https://vimeo.com/152183192” is not embeddable.

@tenacex
Copy link
Contributor Author

tenacex commented Jun 14, 2018

Thanks @simplystuart. There was an issue with our api being case-sensitive even though domains are case insensitive. This is being fixed right now, stand by.

@simplystuart
Copy link

@tenacex any E.T.A. on this?

@tenacex
Copy link
Contributor Author

tenacex commented Jun 18, 2018

Hi Stuart have you tried with the most recent build of player.js. It didn’t require a change to our code just the API repo. I believe that has gone out and it should be working for you, but if not let me know and I’ll check with their team.

@simplystuart
Copy link

@tenacex It works! Thanks!

@tenacex
Copy link
Contributor Author

tenacex commented Jun 18, 2018

Good to hear!

@steve52 steve52 deleted the 403-error branch April 10, 2020 13:25
@steve52 steve52 restored the 403-error branch April 10, 2020 13:25
@steve52 steve52 deleted the 403-error branch April 10, 2020 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants