-2

I created a web application which will show all private videos of only one account.

Now I have to authenticate the account to get list videos. I saw 2 ways to authenticate by ClientLogin and Oauth. Which ClientLogin is deprecated and don't know how to use Oauth to authenticate the default account on server.

I have client_id and client_secret for my app.
I try this example but not working and i don't know what in $get['code'] and how can I put username and password of this account when using OAuth not ClientLogin.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Felix
  • 571
  • 14
  • 34

2 Answers2

1

It's pretty simple.

You can follow the steps at How do I authorise an app (web or installed) without user intervention? (canonical ?) to get a Refresh Token. At Step 8, choose the YouTube API instead of Drive API. Try to choose the most restrictive scope, eg. readonly. You can embed the Refresh Token (securely!!!!) in your app and then use it at any time to generate an Access Token. Thus the stored Refresh Token behaves like a username/password with restricted permissions.

Community
  • 1
  • 1
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
0

Ask you have stated clientLogin is shut down you can not access any Google api using Login and Password. Your application needs to be authenticated

The thing you need to know about the YouTube API is that it does not support service accounts. You will have to use Oauth2. I am not a PHP developer but I have done this previously in C#. What you want to do is possible just a little tricky.

First off as I said you need to use Oauth2. I am hoping that this example is reasonably up to date if not the one for Google analytics is you may have to compare them a little.

Your script will need to be authenticated once using Oauth2. Then by requesting

$client->setAccessType("offline");

you will receive a refresh token. You will then be able to use this refresh token in your script on the server at anytime to request a new access token and access YouTube for that channel.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449