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

Always get play object null. #456

Open
thearith070 opened this issue Oct 29, 2020 · 17 comments
Open

Always get play object null. #456

thearith070 opened this issue Oct 29, 2020 · 17 comments

Comments

@thearith070
Copy link

Issue Summary

A brief but thorough description of the issue.

Reproduction Steps

Detailed steps to reproduce the issue.

Expected Behavior

What do you expect to happen as a result of the reproduction steps?

Actual Behavior

What currently happens as a result of the reproduction steps?

@thearith070 thearith070 changed the title Video video = ...; // obtain a video you own as described above Play play = video.getPlay(); Always get play object null. Oct 29, 2020
@thearith070
Copy link
Author

all these requirements are filled, but I cannot get play object.
Screen Shot 2020-10-29 at 3 32 42 PM
Pls help to check thanks

@RPetrov
Copy link

RPetrov commented Nov 9, 2020

I have the same.


    private fun getVideo(url: String): Video? {
        val video = VimeoClient.getInstance().fetchVideoSync(url, null)
        video?.body()?.apply {
        } ?: Assert.fail(video?.toString())
        return video?.body()
    }

    @Test
    fun getVideoFile() {
        getVideo("videos/${ID}")?.let {
            it.getPlay()?.let { play ->
                // NO! play is null!
            }
        }
    }

It was configured:

        val configBuilder: Configuration.Builder =
            Configuration.Builder("SECRET", "SECRET", "video_files")
                .setCacheDirectory(this.cacheDir)
        VimeoClient.initialize(configBuilder.build())
        // VimeoClient is now ready for use

With my keys I see "files" in response when I use Postman.

@MensObscura
Copy link

MensObscura commented Feb 11, 2021

Hello,

I actually replicate the same issue, despite my ability to see thoses files through postman i never have it within through the SDK :

Here is my Configuration :


VimeoApiConfiguration.Builder configBuilder =  new VimeoApiConfiguration.Builder("cliendID", "secretID", new ArrayList<ScopeType>(Arrays.asList(ScopeType.PUBLIC,ScopeType.VIDEO_ FILES, ScopeType.PRIVATE)));

 Authenticator.Companion.instance().authenticateWithClientCredentials(new VimeoCallback<VimeoAccount>() {
                                                                                 @Override
                                                                                 public void onSuccess(@NotNull VimeoResponse.Success<VimeoAccount> success) {
                                                                                     String accessToken = Authenticator.Companion.instance().getCurrentAccount().getAccessToken();
                                                                                     Log.d("[VIMEO]", "Client Credentials Authorization Success with Access Token: " + accessToken);
                                                                                 }
                                                                                 @Override
                                                                                 public void onError(@NotNull VimeoResponse.Error error) {
                                                                                     String errorMessage = error.getMessage();
                                                                                     Log.d("[VIMEO]", "Client Credentials Authorization Failure: " + errorMessage);
                                                                                 }
        });

As you can see i log the generated token, and when i use this one in Postman, i do not see the "files". So obviously the generated token is not granted the correct rights =)

Actually i tried using
https://api.vimeo.com/oauth/authorize/client?grant_type=client_credentials&scope=public private video_files

turns out that even if the answer is :

 {
    "access_token": "****",
    "token_type": "bearer",
    "scope": "public private video_files",
    "app": {
        "name": "***",
        "uri": "****"
    }
}

The access_token still don't give you any "files", it only seem to work using generated personal token in my case.

Finally since i didn't found a way to log through token as before, after the first authenticate it tried
Authenticator.Companion.instance().exchangeAccessToken("**working_token***",new VimeoCallback<VimeoAccount>() {...}

And i finish with

Client Credentials Authorization Failure: API error: 5000

That's all i got.

Thanks in advance

@shashimalcse
Copy link

same issue

@anthonycr
Copy link
Contributor

anthonycr commented Aug 9, 2021

Sorry that we didn't get around to answering this, and I'm sure y'all probably figured it out by now, but in case you haven't here's what's probably happening.

Authentication with client credentials alone does not actually log you into the account. If you authenticate with client credentials, e.g. Authenticator.instance().authenticateWithClientCredentials(...) you're essentially saying to the API "hey, i don't want to use my client id/secret combo to make requests anymore, give me an auth token i can use as a logged out user." To actually be really logged in, you need to authenticate using Authenticator.instance().authenticateWithCodeGrant(), which requires you to direct the user to the browser and then accept the redirect back to your app. There is an example of this in the auth README as well as in the example Android app in this repository.

The new 2.0.x version of the library has the ability to initialize using an access token, which is the approach I would suggest using. Then you can generate your access token on the Vimeo developer website with the exact access you need and then initialize the client with it without needing to use code grant authentication.

val configuration = VimeoApiConfiguration.Builder(accessToken).build()

Authenticator.initialize(configuration)
VimeoApiClient.initialize(configuration, Authenticator.instance())

@charliepank
Copy link

charliepank commented Aug 9, 2021

Hey, I'm doing the java version of what you posted above:

protected VimeoApiClient doAuthToken() {
String token = "1b75e77e312387c3b83c608aa5ac2879";
VimeoApiConfiguration.Builder vimeoApiConfigurationBuilder =
new VimeoApiConfiguration.Builder(token);
vimeoApiConfigurationBuilder.withCertPinning(false);
VimeoApiConfiguration vimeoApiConfiguration = vimeoApiConfigurationBuilder.build();
Authenticator.initialize(vimeoApiConfiguration);
Authenticator authenticator = Authenticator.instance();
VimeoApiClient.initialize(vimeoApiConfiguration, authenticator);
VimeoApiClient vimeoApiClient = VimeoApiClient.instance();
return vimeoApiClient;
}

running in debug I can then see that I successfully pull a video object back from vimeo but the 'play' object is empty; and the player in my app just gives a message saying it can't play the video when I try calling it using the URI from the video object like this:

vimeoApiClient.fetchVideo(uri, null, null, null, new VimeoCallback<Video>() { @Override public void onSuccess(@NotNull VimeoResponse.Success<Video> video) { System.out.println("Got video"); // use the video Uri uri = Uri.parse(video.getData().getUri()); if (Objects.nonNull(uri)) { System.out.println("Ok, I'll try and play it"); VideoView videoView = (VideoView) findViewById(R.id.videoView1); mediaController.setAnchorView(videoView); videoView.setMediaController(mediaController); videoView.setVideoURI(uri); videoView.requestFocus(); videoView.start(); } else { System.out.println("I won't try and play it"); } }

I'm specifically using vimeo as a place to store the videos I display through my app, so if this doesn't work, I have to find an alternative to vimeo!

@67Samuel
Copy link

I'm facing the same issue as well, using version 2.0.0-alpha.94 and access token initialization. I am able to get other data but the Play object is always null.

@charliepank
Copy link

I'm facing the same issue as well, using version 2.0.0-alpha.94 and access token initialization. I am able to get other data but the Play object is always null.

I raised a support ticket for it with vimeo and pointed them at this conversation in github. I still haven't got a reply from them, in the end I got my money back from vimeo and am now working with Mux - which is the only back-end video store I've found that actually works as it says it will. I recommend you do the same.

@rvanderlinden
Copy link

rvanderlinden commented Sep 7, 2021

implementation "com.github.vimeo.vimeo-networking-java:vimeo-networking:2.0.6"
implementation "com.github.vimeo.vimeo-networking-java:models:2.0.6"

Same issue. Using an access token from a PRO account with scopes public private video_files, I can retrieve a Video that contains a download object but not a play object. This is the exact same access token that in the previous version of this library was able to get the files object.

Making the same call using Postman (GET https://api.vimeo.com/videos/{video_id}) and using the same access token for the Authorization bearer token we get the Video data that contains the download object and again no play object. It does however contain the old files data which we could use, although this is now no longer available in this SDK's Video model.

As a temporary fix I'm considering doing a manual GET using retrofit (bypassing this library) and then first checking for the play data (in case this becomes available in the future) and falling back to the old files data (which may be removed in the future).

It would help if we could temporarily (re-)include the files data in the Video model.

@AKnght
Copy link

AKnght commented Nov 3, 2021

I am having the same issues when auth with clientID and such. However, I have an access token with all the required access scopes and anytime I call to get the videoList via VimeoApiClient.instance().fetchVideoList( uri = uri, fieldFilter = null, queryParams = null, cacheControl = null, callback = vimeoCallback( onSuccess = { val asd = Results.Success(it.data) Log.d("Vimeo", "videoList Successful") }, onError = { vimeoError -> Log.d("Vimeo", "videoList UNNNNNsuccessful") } ) )

    I get this ApiError(developerMessage=The operation could not be completed within the permitted time., errorMessage=We're like, soooo popular. Please try again in a few minutes., errorCode=1504, invalidParameters=null, link=null)

If we can get a FULL example of this working with the access token in the examples that would be great. Also, splitting up your readme into 2 different sections instead of having AccessToken or OtherWay may ease a lot of confusion.

@charliepank
Copy link

charliepank commented Nov 3, 2021 via email

@AKnght
Copy link

AKnght commented Nov 4, 2021

Yeah, it seems that way. If the issue isn't resolved we will have no choice but to switch providers.

@charliepank
Copy link

charliepank commented Nov 6, 2021 via email

@AKnght
Copy link

AKnght commented Nov 6, 2021

Thank you @charliepank I'll look into that. So far I created a very slim Vimeo Library in the last 2 days that allows me to pull the videos and play them with no issues. The only downside is Vimeo is so slow at delivering requests in the first place straight from their API. Does Mux have a good api and/or android/ios sdk?

@charliepank
Copy link

charliepank commented Nov 6, 2021 via email

@67Samuel
Copy link

67Samuel commented Jul 14, 2022

Update: I managed to get the play object and videos as expected with the following dependencies:

implementation "com.github.vimeo.vimeo-networking-java:vimeo-networking:2.0.10"
implementation "com.github.vimeo.vimeo-networking-java:models:2.0.10"

@damanpreet97
Copy link

damanpreet97 commented Jan 19, 2023

I have tried this on library version 3.12.0 & it works:-

val confBuilder = VimeoApiConfiguration.Builder(accessToken)
val configuration = confBuilder.build()
Authenticator.initialize(configuration)
VimeoApiClient.initialize(configuration, Authenticator.instance())

    VimeoApiClient.instance()
        .fetchVideo(finalUrl, null, null, null, object : VimeoCallback<Video>{
            //here url should be like ""https://api.vimeo.com/videos/{video_id}" otherwise it wasn't working whatever the url was

            override fun onError(error: VimeoResponse.Error) {
                Logger.d("TAG", "vimeo error = ${error.message}")
                Toast.makeText(applicationContext, error.message, Toast.LENGTH_SHORT).show()
            }

            override fun onSuccess(response: VimeoResponse.Success<Video>) {
                val video = response.data
                
                Log.d("TAG", "vimeo video user = ${response.data.user?.name}")
                
                    val play: Play? = video.play
                    val progressiveFiles: List<ProgressiveVideoFile>? = play.progressive
                        
                val linkToMp4File: String? = progressiveFiles?.get(0)?.link
                        runExoplayer(linkToMp4File)
                        
                }
                })
                
                In this Play data will be there iff the video is created by the same user whose access token you are using. 
                
                You can verify this by comparing the user you are getting inside the video object (Logged above) with the user with which you have authenticated (shown below) :-
                VimeoApiClient.instance().fetchCurrentUser(null, null, object : VimeoCallback<User>{
        override fun onError(error: VimeoResponse.Error) {

        }
        override fun onSuccess(response: VimeoResponse.Success<User>) {
            Logger.d("TAG", "vimeo user = ${response.data.name}")
        }
    })
    
    Only those videos will have Play data whose user is same as video creator/member on vimeo account as your access token owner.
    This is mentioned in the official document here https://developer.vimeo.com/api/authentication (Understanding the authentication process)

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

No branches or pull requests

10 participants