CyberNinja
CyberNinja

Reputation: 864

Get access_token from google service account for embed api

I've wanted to embed api without my user logging in to their account. I'm new to google api and I wanted to use embed api Like this one I've been searching since yesterday how to implement this either by javascript or .net.

I have this code in .net

       string keyFilePath = Server.MapPath("~/Libraries/googleKey/key.json");
        string json = System.IO.File.ReadAllText(keyFilePath);


        var cr =  JsonConvert.DeserializeObject<PersonalServiceAccountCred>(json);

        var xCred = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(cr.client_email)
        {
            Scopes = new[] {
          AnalyticsReportingService.Scope.AnalyticsReadonly
    }
        }.FromPrivateKey(cr.private_key));

I'm getting a null token, i'm confused, most examples are in php or python.

Upvotes: 1

Views: 64

Answers (1)

Leeyoh_it_is
Leeyoh_it_is

Reputation: 73

you can use a service Account, make sure you have access granted to the service account

Upvotes: 1

Related Questions