Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8366065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:49:02+00:00 2026-06-09T12:49:02+00:00

All the samples I’v seen only support ‘user’ accounts where a user has to

  • 0

All the samples I’v seen only support ‘user’ accounts where a user has to be present.

Looks like latest version of OAuth2 supports service accounts for server to server authentication where humans not present but I am struggling to find any libraries that support it or examples of in use.

https://developers.google.com/accounts/docs/OAuth2ServiceAccount

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:49:03+00:00Added an answer on June 9, 2026 at 12:49 pm

    I don’t (yet) have any C# examples of authorization via service accounts, but the Google APIs support service account authorization flow. Here’s an example of using this authorization flow with the Google BigQuery API, in Java & Python, using the Google APIs Client Libraries for these languages (http://code.google.com/p/google-api-python-client/ and http://code.google.com/p/google-api-java-client/).

    import com.google.api.client.http.HttpTransport;
    import com.google.api.client.http.javanet.NetHttpTransport;
    import com.google.api.client.json.JsonFactory;
    import com.google.api.client.json.jackson.JacksonFactory;
    
    import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
    import com.google.api.services.bigquery.Bigquery;
    import com.google.api.services.bigquery.Bigquery.Datasets;
    import com.google.api.services.bigquery.model.DatasetList;
    
    import java.io.File;
    import java.io.IOException;
    import java.security.GeneralSecurityException;
    
    
    public class BigQueryJavaServiceAccount {
    
      private static final String SCOPE = "https://www.googleapis.com/auth/bigquery";
      private static final HttpTransport TRANSPORT = new NetHttpTransport();
      private static final JsonFactory JSON_FACTORY = new JacksonFactory();
    
      public static void main(String[] args) throws IOException, GeneralSecurityException {
        GoogleCredential credential = new GoogleCredential.Builder().setTransport(TRANSPORT)
            .setJsonFactory(JSON_FACTORY)
            .setServiceAccountId("XXXXXXX@developer.gserviceaccount.com")
            .setServiceAccountScopes(SCOPE)
            .setServiceAccountPrivateKeyFromP12File(new File("my_file.p12"))
            .build();
    
        Bigquery bigquery = Bigquery.builder(TRANSPORT, JSON_FACTORY)
            .setApplicationName("Google-BigQuery-App/1.0")
            .setHttpRequestInitializer(credential).build();
    
        Datasets.List datasetRequest = bigquery.datasets().list("publicdata");
        DatasetList datasetList = datasetRequest.execute();
        System.out.format("%s\n", datasetList.toPrettyString()); 
    }
    

    Same snippet implemented in Python:

    import httplib2
    
    from apiclient.discovery import build
    from oauth2client.client import SignedJwtAssertionCredentials
    
    # REPLACE WITH YOUR Project ID
    PROJECT_ID = 'XXXXXXXXXXX'
    # REPLACE WITH THE SERVICE ACCOUNT EMAIL FROM GOOGLE DEV CONSOLE
    SERVICE_ACCOUNT_EMAIL = 'XXXXX@developer.gserviceaccount.com'
    
    f = file('key.p12', 'rb')
    key = f.read()
    f.close()
    
    credentials = SignedJwtAssertionCredentials(
        SERVICE_ACCOUNT_EMAIL,
        key,
        scope='https://www.googleapis.com/auth/bigquery')
    
    http = httplib2.Http()
    http = credentials.authorize(http)
    
    service = build('bigquery', 'v2')
    datasets = service.datasets()
    response = datasets.list(projectId=PROJECT_ID).execute(http)
    
    print('Dataset list:\n')
    for dataset in response['datasets']:
      print("%s\n" % dataset['id'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From all the samples I've seen using NAudio's MeteringSampleProvider to update a VolumeMeter control,
I see code like this in Android samples all the time? try { ...
All the samples I have seen so far seem to be using an earlier
Consider the SlidingDrawer in Android. All samples I've seen have a large button as
I'm trying to use an event listener for the first time. All samples I've
I'm very confused by the MSDN samples. And all the samples I find generally
I want to remotely uninstall apps from clients using c#. In all the samples
Thats it really.. I am using VS2008 Express. All the samples say just to
I have a table (MySQL) that captures samples every n seconds. The table has
I need to draw a waveform in an NSView. (I have all the samples

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.