Google Custom Search API - Engine Retrieving Engine Data Fails -


i need crud on custom search engines. documentation, looks pretty straight forward. keep getting 401 responses though.

i using google.apis.oauth2.v2 token:

string serviceaccountemail = "blahblahblah@developer.gserviceaccount.com";  var certificate = new x509certificate2(@"key.p12", "blah", x509keystorageflags.exportable);  var credential = new serviceaccountcredential(    new serviceaccountcredential.initializer(serviceaccountemail)    {       scopes = new[] { "https://www.googleapis.com/auth/cse" }    }.fromcertificate(certificate));  bool result = credential.requestaccesstokenasync(cancellationtoken.none).result; tokenresponse token = credential.token; 

i add token following request (authorization: bearer mytoken):

get http://cse.google.com/api/<user_id>/cse/<cse_id> 

there few things jump @ me.

  1. exact quote documentation:

although can set http requests url http://cse.google.com/api/[user_id]/cse/[cse_id], recommend using following url instead:

http://cse.google.com/api/[user_id]/cse/[cse_id]

note both url's same.

  1. in authentication section, sample using clientlogin, deprecated. no samples oauth 2.0.

  2. in document's example, says:

each custom search engine identified unique id created combining user id custom search engine id, separated colon, this:

011737558837375720776:mbfrjmyam1g in case, user id 011737558837375720776, , search engine id mbfrjmyam.

you have noticed search engine id 2 characters short of looks should be.

  1. nowhere have seen scope "https://www.googleapis.com/auth/cse". copied stackoverflow post.

i understand long question, hope next person @ , consider these points.

anyone knows why 401s?


Comments