android - Reply to Reviews API | Google Play Developer API -
i working on creating web/app company (in free time) provide access our customers retrieve , reply google reviews apps have published them. google has released reply reviews api should work this.
i haven't been able figure out gaining access portion.
i'm trying use service account. i've created oauth2 service account, granted access, downloaded private key, , tired follow sample provided here (below).
i know in example using plus service. questions are, service supposed using? i'm assuming plus service not want.
is generating certificate way correct way auth_token (in reply reviews api documentation)?
thanks help!
using system; using system.security.cryptography.x509certificates; using google.apis.auth.oauth2; using google.apis.plus.v1; using google.apis.plus.v1.data; using google.apis.services; namespace google.apis.samples.plusserviceaccount { /// <summary> /// sample demonstrates simplest use case service account service. /// certificate needs downloaded google developers console /// <see cref="https://console.developers.google.com/"> /// "create client id..." -> "service account" -> download certificate, /// rename "key.p12" , add project. don't forget change build action /// "content" , copy output directory "copy if newer". /// </summary> public class program { // known public activity. private static string activity_id = "z12gtjhq3qn2xxl2o224exwiqruvtda0i"; public static void main(string[] args) { console.writeline("plus api - service account"); console.writeline("=========================="); string serviceaccountemail = "service_account_email_here"; var certificate = new x509certificate2(@"key.p12", "notasecret", x509keystorageflags.exportable); serviceaccountcredential credential = new serviceaccountcredential( new serviceaccountcredential.initializer(serviceaccountemail) { scopes = new[] { plusservice.scope.plusme } }.fromcertificate(certificate)); // create service. var service = new plusservice(new baseclientservice.initializer() { httpclientinitializer = credential, applicationname = "plus api sample", }); activity activity = service.activities.get(activity_id).execute(); console.writeline(" activity: " + activity.object.content); console.writeline(" video: " + activity.object.attachments[0].url); console.writeline("press key continue..."); console.readkey(); } } }
my questions are, service supposed using? i'm assuming plus service not want.
to work reply reviews api, provide authorization using either oauth client or service account.
so there 2 ways.
- using oauth2: installed application
edit /resources/client_secrets.json file , add client id, client secret , redirect uris. execute sample class using main() method begin auth flow:
a browser window open , ask login. make sure account has appropriate permissions in google play developer console. accept permissions dialog. browser should display authentication flow has completed. close window , go ide , check console output. script output list of apks. tokens stored in .store/android_publisher_api in home folder. remove file restart auth flow.
- using oauth2: service accounts edit applicationconfig.java , add service account email address. copy service account key file, generated in google apis console same directory , rename key.p12. execute sample class using main() method in ide script output list of apks.
here's full sample in github.
Comments
Post a Comment