I use Youtube Data API to create request, the code here:
YouTubeRequestSettings settings = new YouTubeRequestSettings("YoutubeUpload", "developer_key", "myemail#gmail.com", "mypass");
YouTubeRequest request = new YouTubeRequest(settings);
var feed = request.GetStandardFeed(YouTubeQuery.MostPopular);
But I could not found "developer key" on google console. Google's document specify link to get developer key: https://code.google.com/apis/youtube/dashboard/
But it can not log in.
Can you help me create a simple request to Youtube Data API
Thank you so much!
I am not aware of anything Google refer to as a 'Developer Key' - but you can get/create Credentials at https://console.developers.google.com/apis/credentials
Related
I want to get the timeline post of the other user using weibo api but not getting.weibo API. I am using few API Call like user_timeline,trends but not getting any proper data. please, let me know if I missing any API or any settings in App. I have appKey, secret key and redirect url.
As far as I can tell, the API calls that would get you this info have all been restricted. The English documentation is not updated, but the chinese documentation specifies for example that you can only use User_timeline to get your own timeline, not others.
http://open.weibo.com/wiki/2/statuses/user_timeline
接口升级后:uid与screen_name只能为当前授权用户
I want to automatically upload videos to YouTube without user involvement so I've created a service account, jumped through the hoops, all was looking great, then the upload, chunk one, is attempted and my code bombs with this Google_Exception exception:
"Failed to start the resumable upload (HTTP 401: youtube.header, Unauthorized)"
I then dug and found on the YouTube API v3 error information:
https://developers.google.com/youtube/v3/docs/errors
"This error is commonly seen if you try to use the OAuth 2.0 Service Account flow. YouTube does not support Service Accounts, and if you attempt to authenticate using a Service Account, you will get this error."
Is this correct? I cannot use a service account to upload video to YouTube automatically?
(that was a waste of a couple of days hard work!)
Yes, it is correct.
The way forward is to do a manual authorisation and grab the resultant 'refresh token' and then use that for any automated uploads.
Ensure to add the refresh token to the PHP Google_Client object prior to any other action.
I am now automatically uploading to YouTube.
For anyone attempting to do this today, be aware that any uploads will be set as "Private (Locked)" if they are uploaded using the API unless/until the app is submitted for verification and approved.
https://github.com/porjo/youtubeuploader/issues/86
YouTube requires verification of the OAuth App/credentials used for upload, otherwise the video will be locked as Private.
It's possible to get an app approved, but if you're doing a personal project, it's less likely.
More: https://github.com/porjo/youtubeuploader/issues/86
Yes you can use Service Accounts for Youtube. One way is to add the service account to a CMS where the content owner is part of. When you retrieve an access_token for the Service Account, you can work with the content owners videos.
Looks like this, using Javascript and a npm package:
import { google } from 'googleapis';
const youtube = google.youtube('v3');
const fetchYoutubeData = async (keyfile, scopes) => {
const auth = new google.auth.GoogleAuth({
credentials: keyfile,
scopes,
});
const accessToken = await auth.getAccessToken();
const { data } = await youtube.videos.list({
part: ['snippet'],
id: 'YOUR_VIDEO_ID',
access_token: accessToken
});
return data;
}
Note that the keyfile is the JSON you downloaded from Gcloud when creating the service accounts keys. NOT the path pointing to the file! If you want to use path, use this instead:
const auth = new google.auth.GoogleAuth({
keyFile: 'PATH_TO_KEYFILE_IN_FILE_SYSTEM',
scopes: ['READ_STUFF', 'WRITE_STUFF'],
});
Further reading on server-server authentication using Oauth2
I've been trying to access Calendar v3 API with a service account. I have already added the scope https://www.googleapis.com/auth/calendar from the admin console and shared my calendar with that service account's email address.
I have also been accessing https://www.googleapis.com/auth/coordinate scope with the very same service account and it works fine.
Also, tried revoking access as said here: Why is Google Calendar API (oauth2) responding with 'Insufficient Permission'?
All that, and I am still getting;
{"error"=>
{"errors"=>
[{"domain"=>"global",
"reason"=>"insufficientPermissions",
"message"=>"Insufficient Permission"}],
"code"=>403,
"message"=>"Insufficient Permission"}}
Am i missing something?
Try to add to you scope 'userinfo.email' and enable in Developers console "Contacts API" and "Google+ API". I've spent 2 weeks searching for answer to this question, and this trick has worked for me.
Did you have any joy with this? I've hit the same brick wall.
UPDATE:
$key = file_get_contents($key_file_location);
$scopes = array('https://www.googleapis.com/auth/calendar');
$cred = new Google_Auth_AssertionCredentials(
$service_account_name,
$scopes,
$key
);
This worked for my authorization, after sharing the calendar with the service email account.
I think if you use Google Calendar Quickstart for Ruby, I think you should delete your credentials in the specified path...I try it and it works well... You can see where the credentials is put in here
CREDENTIALS_PATH = File.join(Dir.home, '.credentials',
"calendar-ruby-quickstart.yaml")
In your home dir, you may find a dir which Google store your credentials after you approve Google request to access your data.
first of all change
static string[] Scopes = { CalendarService.Scope.CalendarReadonly };
to
static string[] Scopes = { CalendarService.Scope.Calendar };
and then in your documents folder delete .credentials folder
and run again.
this worked for me!
I am trying to retrieve all my contacts using Google Contact API. For this I used Oauth authentication and Google Contact API.
I got "Access Token" from Google OAuth 2.0. But here my question is how can I retrieve my contacts using this "Access Token". How to use this access token in my code. Can any one help me on this please. If possible any sample code snippet please.
I stuck over here. Please help me on this...
Thanks & Regards,
Amar Thondapu
This sample should help: https://github.com/jcleblanc/oauth/blob/master/oauth2-php-google/complete.php. Specifically, look at line 21:
$contact_url = "https://www.google.com/m8/feeds/contacts/default/full?oauth_token=" . $token->access_token;
That URI (with the access token) should be where you can make an HTTP GET request to in order to obtain the contacts. Hopefully they haven't changed the URI in the 2 years since that sample was created.
Jon
I have an account with google which can login absolutely fine via www.youtube.com. However when I use the following code via the Youtube API:
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$username = 'EXAMPLE#EXAMPLE.COM',
$password = 'EXAMPLE',
$service = 'youtube',
$client = null,
$source = 'EXAMPLE', // a short string identifying your application
$loginToken = null,
$loginCaptcha = null,
"https://www.google.com/accounts/ClientLogin");
I receive the following error: 'Authentication with Google failed. Reason: BadAuthentication'
Why would I be able to login to google & youtube with the exact same credentials but not to the API?
Maybe you have enabled 2-step verification on your gmail account,
take note of the message at the top of this page:
https://developers.google.com/accounts/docs/AuthForInstalledApps
The problem is that you're using clientLogin, witch is intended for installed applications, not web apps.
You should change this to AuthSub in order to get a token to make API calls.
That said, we have the same issue and we haven't change that (there's not enougth time to change aaaall auth changes in Google, Twitter and Facebook, isn't it?). The solution for us was to inform clients with that problem thet they have to disable the captcha by clicking this link and follow the instructions: http://www.google.com/accounts/DisplayUnlockCaptcha
That's not the right way, but it's a way