Programmatic access to Google API Console's functionality - google-api

I would like to configure the Google API services programmatically instead of having to go through the API Console. For example, I would like to be able to the following types of things programmatically:
Create OAuth and API Key credentials; this would include generating
the client id\secret, setting the redirect uri, downloading the
client_secrets.json file, etc.
Get the list of projects for a user
Enable\disable services for a specified project
Does Google provide any APIs for configuring services so that I don't have to use the API Console's GUI? All of the documentation I have seen has indicated that the only way to do this is through the API Console’s GUI.

You can use the Cloud Resource Manager API to get the list of projects for a user. Unfortunately, public APIs don't exist for the other things at this time.

Related

Programmatically updating redirect_uris in a Google app OAuth client

I created an app in the Google Cloud console with an OAuth 2.0 client.
Can I programmatically update the list of allowed redirect URIs to allow different subdomains? (a.example.com, b.example.com, etc.)
The only way I was able to do it was via the GUI at https://console.cloud.google.com/apis/credentials which is not scalable.
I was looking for this same thing.
All I could find was this, but it is only for Identity Aware Proxy
https://cloud.google.com/sdk/gcloud/reference/iap/oauth-clients/create

Use firebase admin with REST

I'm using Deno instead of node as a runtime, which makes me unable to use firebase-admin. I would like to implement the listUsers from the admin sdk in REST, but have not found any REST api references. Is there a way to use the firebase-admin sdk with REST?
You are looking for the Identity Toolkit APIs, the accounts:batchGet to be specific. You'll need an access token to use those APIs since you cannot use default credentials with the REST API. Checkout the documentation for the same.
You can use the API explorer linked above to test APIs from the browser itself.

Okta integration possible with existing system?

We have a custom built web app backed by a REST API. We already have existing user accounts that are created via our system. We've just recently integrated Domo to do reporting and they recommend Okta.
Is it possible to get have users sign in on our site and in the background also sign them into Okta via an API call/OAUTH request etc?
Yes it is. The methods are available via the API, and I just created app that demos exactly this in Python. Check out http://developer.okta.com/docs/api/resources/authn.html for links to test stuff in Postman. My basic approach was to have Okta be the system of record, but it can certainly be the other way :)

Simplest way authenticate with Python Google APIs to access own accounts

The main use case is using IPython as CLI to my own Google accounts. What I am really after is minmizing the fussing around between starting the IPython shell and actually issuing usefull calls against the API.
The docs for authenticating with Google APIs focus on setting up application which other user will use to access their data.
This leads to a lengthy Oauth dance involving a browser in order to allow other users to authenticate without compromising their credential.
However, I do not mind sharing my private credentials with myself. I am not planning on sharing the code. If I did share the code I would use something like dotenv to separate the credentials from the code.
Twitter provides developers a second set of credentials
that allows developers to access their own accounts for testing.
Thus it is possible to access ones own account programmatically
by just providing to sets of credentials: the developer credentials that allow the calls to the API and the other credentials that grant access to the developers own data. For example:
from twitter import *
t = Twitter(
auth=OAuth(token, token_key, con_secret, con_secret_key))
# Get your "home" timeline
t.statuses.home_timeline()
# Update your status
t.statuses.update(
status="Tweeting from Python")
Where con_secret* are the developer credentials and
and token* are the account access credentials.
How can I do something equally simple with Google APIs?
Where can I get credentials to access my own account?
How would I use them in Google API?
As an example what would be the simplest procedure for retrieving the contents from one of my own Youtube playlists?
I have com to think that a Python headless browser library could be give me what I need. I have asked a related question on SE Software Recommendations
https://softwarerecs.stackexchange.com/questions/35744/python-headless-browser-library-for-oauth2-authentication-from-ipython-console
I would like to download a set of credentials
Google offers this ability through it's client_secrets.json file. There are different ways to download this, depending on the type of account you want to use (Web application, installed application, Service account). The different techniques can be found here .
Store the credentials locally and keep using them without requiring
new credentials every call
This also isn't a problem, the client secret is valid until you renew it - AFAIK there is no automatic expiry unless you specify otherwise.
Once you have downloaded your client_secrets.json, store the file in a non-public directory (normally inside your project directory/config).
Similar to the downloading of the file, there are different techniques (flow classes) to use the JSON file depending on what type of account you are using. As an example, the below would be used for installed and web applications;
from oauth2client.client import OAuth2WebServerFlow
...
flow = OAuth2WebServerFlow(client_id='your_client_id',
client_secret='your_client_secret',
scope='scope URL here',
redirect_uri='http://example.com/auth_return')
Other flow class examples can be found here
Hope this helps - If you need further information, the official documentation (which be warned, can be incredibly inaccurate and confusing) can be found here https://developers.google.com/api-client-library/python/guide/aaa_oauth

Google custom search API with OAuth2

Is it possible to get authorized for Google's custom search API with OAuth2 instead of using their ClientLogin, which would mean I'd need to build a whole UI to deal with user's login/password/captcha, plus I'm not a fan of inputting secure information like that on my own system. I'd rather rely on OAuth2 and login directly to Google
I've looked around but haven't been able to find anything for the scope part of the url eg scope="https://www.google.com/m8/feeds" for authenticating with their Contacts API.
Note: I'm using Ruby to develop this.

Resources