Reputation: 435
I'm trying to implement resumable uploads for youtube using the javascript client API. I've managed to get the login working using the g-signin2
button, but I can't get the access_token to send with the requests. This is how I render the sign in button:
<span
class="g-signin2"
data-onsuccess="youtubeUploaderSigninCallback"
data-scope="https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/youtube">
</span>
And I'm using the following script files loaded from google (I can't seem to get one working without the other)
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://apis.google.com/js/client.js" async defer></script>
I'm using code edited samples from https://developers.google.com/youtube/v3/code_samples/javascript#upload_video for resumable uploads using XHR.
But these examples use the auth functions marked as deprecated here: https://developers.google.com/api-client-library/javascript/reference/referencedocs
So the main thing I changed is using the auth2
and g-signin2
instead of result.access_token
and g-signin
.
So I've been trying to use the auth2
functions to get the access tokens, but the access_token
property is undefined when I execute the following code
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse()
The way I'm trying to get the access token is documented here: https://developers.google.com/api-client-library/javascript/features/cors#making-authenticated-requests
So these are my options, I guess:
hg
is a minified property indeed and now no longer existsCan anyone help me with this? I've been looking for an acceptable solution for a few hours and I feel like crying now... all alone and desperate.
Thanks in advance, Robbe
PS: I've also posted this question on google groups
Upvotes: 5
Views: 5531
Reputation: 1
This snippet is working perfectly
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().access_token
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().id_token
etc...
Upvotes: 0
Reputation: 3274
gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().access_token
Upvotes: 13