Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

YouTube API - The API Key and the authentication credential are from different projects

$
0
0

I am trying to get videos from youtube with my C# application, with "https://youtube.googleapis.com/youtube/v3/search?forMine=true&order=date&type=video&part=snippet&key={key}&access_token={token}" but I receive this error:

"error": {"code": 400,"message": "The API Key and the authentication credential are from different projects.","errors": [      {"message": "The API Key and the authentication credential are from different projects.","domain": "global","reason": "badRequest"      }    ],"status": "INVALID_ARGUMENT","details": [      {"@type": "type.googleapis.com/google.rpc.Help","links": [          {"description": "Google developer console API key","url": "https://console.developers.google.com/project/{MyProjectCode}/apiui/credential"          }        ]      },      {"@type": "type.googleapis.com/google.rpc.ErrorInfo","reason": "CONSUMER_INVALID","domain": "googleapis.com","metadata": {"consumer": "projects/{MyProjectCode}","service": "youtube.googleapis.com"        }      }    ]  }

But I can see only 1 API Key and 1 OAuth 2.0 Client ID (with Client ID and Client Secret) on https://console.cloud.google.com/apis/api/youtube.googleapis.com/credentials?authuser=1&project={MyProject} site

Could you please help how can I fix this ?

Code:

var token = Helper.Decrypt(ytConn.AccessToken);var url = "https://youtube.googleapis.com/youtube/v3/search? forMine=true&order=date&type=video&part=snippet&key=" + _key +"&access_token=" + token;videos = Helper.GetFromAPI<Videos>(url, token);

it calls this:

public static T GetFromAPI<T>(string url, string token){                WebRequest request = WebRequest.Create(url);    request.Method = "GET";    ServicePointManager.SecurityProtocol =     SecurityProtocolType.Tls12;    request.Headers.Set("Authorization", "Bearer " + token);                    request.ContentType = "application/json; charset=utf-8";    T type = default(T);    try    {        using (WebResponse response = request.GetResponse())        {            using (Stream dataStream = response.GetResponseStream())            {                using (StreamReader reader = new                 StreamReader(dataStream))                {                    string responseFromServer = reader.ReadToEnd();                    type = JsonConvert.DeserializeObject<T>                     (responseFromServer);                }            }        }    }}

Thanks in advance


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>