Ben's Blog

building, self sustainability ben March 26, 2016

Started staining cedar shingles

The house will become beautiful this Summer.IMG_4062

self sustainability, water ben March 24, 2016

Happy campers

FullSizeRender(2)Stainless steel Maine made Bison hand pump. Gets us water from 72′ deep, which at 1.5 gallon per foot is about 100 gallons that we get to pump from. We’re still not sure how fast the well fills back up 72′ deep, but we measured it at the top and it gives us a couple of gallons per hour.

So we still need to understand how fast the water comes up the water column. We also need to come up with a solution to prevent the water from rising above the freeze line. Fortunately, we have 8 months until next Winter to figure it out.

We aren’t drinking the water just yet, we need to wait and get it tested first. The pump operates very smoothly and pumps out a few gallons in little time and with little effort. Our effort to gallon ratio is about to go way down, this will be an enormous improvement from where we are now. Eventually we’ll run water to the house, there is still a lot of unknown on how we’ll do this, but we have ideas for manual processes that are part of a daily routine or solar instrumentation.

maple syrup, self sustainability ben March 18, 2016

Protected: Syrup loot so far

This content is password-protected. To view it, please enter the password below.

miscellaneous ben March 18, 2016

The next level of slacktivism

IMG_3708Funny thing is that inside are the cereals.

I.T. ben March 16, 2016

Using Google's APIs with Python scripts

I was never able to find centralized, succinct and example based documentation for doing domain delegated API calls with Google. Hopefully here is exactly this documentation from all the pieces I gathered along the way.

Service Account Creation

  1. Go to https://console.developers.google.com/start and create a new project.
    Screen Shot 2016-03-15 at 10.11.31 AM
  2. Call it whatever you want
    Screen Shot 2016-03-15 at 10.11.48 AM
  3. Enable the right APIs that this project will use We’ll do drive API for the purpose of this testing
    Screen Shot 2016-03-15 at 10.15.06 AMScreen Shot 2016-03-15 at 10.16.40 AMScreen Shot 2016-03-15 at 10.16.48 AM
  4. Go to the “Credentials” screen
    Screen Shot 2016-03-15 at 10.18.08 AM
  5. Create a “Service Account Key”
    Screen Shot 2016-03-15 at 10.18.33 AM
  6. Make it a “New service account” and give it a nameScreen Shot 2016-03-15 at 10.19.17 AMScreen Shot 2016-03-15 at 10.20.09 AMScreen Shot 2016-03-15 at 10.23.45 AM
  7. Download that JSON file that follows.
    Screen Shot 2016-03-15 at 10.23.53 AM
    This file contains the credentials for the account you just created, treat it with care, anyone getting their hands on it can authenticate with the account. This is especially critical since we are about to grant domain delegation to the account we created. Any one with access to this file is essentially able to run any API call masquerading as anyone in your Google Apps domain. This is for all intents and purposes a root account.

Domain Delegation

  1. Back on the “Credentials” screen, click “Manage service accounts”
    Screen Shot 2016-03-15 at 10.26.43 AM
  2. Edit the service account you just created
    Screen Shot 2016-03-15 at 10.28.23 AM
  3. Check the “Enable Google Apps Domain-wide Delegation” checkbox and click “Save”.
    Screen Shot 2016-03-15 at 10.30.28 AM
    Google at this points needs a product name for the consent screen, so be it.
  4. At this point, if everything went well, when you go back to the “Credentials” screen, you will notice that Google create an “OAuth 2.0 client ID” that is paired with the service account you created.

Domain delegation continued, configuring API client access

Granting domain delegation to the service account as we just did isn’t enough, we now need to specify the scopes for which the account can request delegated access.

  1. Go to your Google Apps domain’s Admin console.
  2. Select the Security tabScreen Shot 2016-03-09 at 11.15.40 AM
  3. Click “Show more” -> “Advanced Settings” Screen Shot 2016-03-09 at 11.15.52 AM
  4. Click “Manage API client access Screen Shot 2016-03-09 at 11.16.08 AM
  5. In the “Client Name” field, use the “client_id” field from the json file you downloaded earlier. You can get it via the following command:

    [bash]cat ~/Downloads/*.json | grep client_id | cut -d ‘"’ -f4[/bash]

    In the “One or More API Scopes” field use the following scope:

    [code]https://www.googleapis.com/auth/drive[/code]

    Screen Shot 2016-03-15 at 11.00.36 AM
    If you want to allow more scopes], comma separate them. This interface is very finicky, only enter URLs and don’t copy/paste the description that show up for previous entries. There also might be a few minutes delay between you granting a scope and its taking effect.

  6. Click “Authorize”, you should get a new entry that looks like this:
    Screen Shot 2016-03-15 at 11.01.51 AM
    If you need to find the URL for a scope, this link is helpful.

Scripting & OAuth 2.0 authentication

Okay! The account is all set up on the Google side of things, let’s write a Python script to use it. Here’s your starting point:

google_api_script.py

This scripts contains all the functions to get you started with making API calls to Google with Python. It isn’t the simplest form it could be presented in but it solves a few issues right off the bat:

  • All Google interactions are in the “google_api” class, this allows for efficient use of tokens. When “subing as” a user in your domain, the class will keep track of access tokens for users and only re-generate them when they expire.
  • Exponential back-off is baked-in and generalized to anything unusual gotten back from Google (based on observation).
  • SIGINT will get handled properly

Before running the script, you may need to:

[bash]sudo apt-get update && sudo apt-get install python-pycurl[/bash]

Running the script is done as such:

[bash]./google_api_script.py /path/to/json/file/you/downloaded/earlier.json account.to.subas@your.apps.domain[/bash]

It will simply run the “get about” Drive API call and print the result. This should allow you to verify that the call was indeed executed as the account you specified in the arguments.

Once you’ve ran this script once, the sky is the limit, all the Drive API calls can be added to it based on the get_about function.

Important note on scopes: the same way that you granted domain delegation to certain comma separated scopes in the Google Apps Admin Console earlier; this script needs to reflect the scopes that are being accessed and the same space separated list of scopes need to be part of your jwt claim set (line 78 of the script). So if you need to make calls against more than just drive, make sure to update scopes in both locations or your calls won’t work.

More scopes & more functions

Taking it one step further with the Google Enforcer. This is the project that lead me down the path of writing my own class to handle Google API calls. While it is not quite ready for public use, I’m publishing the project here as it is an excellent reference to making all kinds of other Google API calls; some doing POSTs, PUTs, DELETEs, some implementing paging, et cetera.

Download:
google_drive_permission_enforcer_1.0.tar.gz

The purpose of this project is to enforce on the fly permissions on a directory tree. There is a extravagant amount of gotchas to figure out to do this. If you are interested in implementing it with your organization, please leave a comment and I can either help or get it ready for public use depending on interest.

This project works towards the same end as AODocs, making Google Drive’s permission not completely insane as they are by default.

Here are the scopes I have enabled for domain delegation for this project.

Screen Shot 2016-03-15 at 4.55.25 PMProblems addressed by this project:

  • domain account “subbing as” other users AKA masquerading
  • a myriad of Google Drive API calls focused on file permissions
  • watching for changes
  • crawling through directory hierarchy
  • threading of processes to quickly set the right permissions
  • disable re-sharing of files
  • access token refreshing and handling
  • exponential back-off
self sustainability, water ben March 07, 2016

From 380' into the earth

Not exactly gushing out but the fact that it reaches ground level will make a hand pump quite doable. The whole experience was quite a roller-coaster of emotions. I find myself staring in fascination at the water oozing out.IMG_3603

maple syrup, self sustainability ben March 04, 2016

First ever home made Maple Syrup

IMG_1288

all out geekery, I.T. ben March 04, 2016

IPv6 link-local address to MAC address online converter

The converter

It can also be addressed directly via:
https://ben.akrin.com/ipv6_link_local_to_mac_address_converter/?mode=api&ipv6=fe80::5074:f2ff:feb1:a87f
for all your API needs.

Description

This converter was implemented per Dave Russell’s suggestion as a follow up to the MAC address to IPv6 link-local address online converter. If you are interested in the steps behind this conversion, they are simply a reverse of the original Mac->IPv6 converter.

Please note that of the various IPv6 notations, the one this script will expect is fe80::xxxx:xxxx:xxxx:xxxx.

self sustainability, water ben March 01, 2016

Getting a well drilled

Unfortunately not a whole lot of water at 300ft. We’ll see where static is tomorrow and decide if we go deeper.IMG_3600

Very impressive piece of machineryIMG_3597Not a very green process.

miscellaneous ben March 01, 2016

Swoosh

It’s hard to tell what happened last night, let’s just say we felt like the roof was going to be ripped from the house. We felt every gust of wind move the house, I have never experienced anything like it. We slept downstairs with the windows covered that’s how bad it was. Everything was a mess outside the following morning including things I never thought could be brought down by the wind.

No bees in it yet thankfully.

IMG_3520

Fuck you wind! Not the outside shower!IMG_3519

I ended up outside in the middle of it to weight down a couple of things, it was surreal. Today at town meeting, I’ve talked with other people from our hill who experienced the same crazy night.

Posts pagination

← Previous 1 … 81 82 83 … 119 Next →

Recent Posts

  • Red Shouldered Hawk
  • Protected: 2026 Fireflies
  • Gondola PlottyBot v2
  • Corkscrew Sounds a Mystery no Longer
  • Copper

Recent Comments

  1. ben on PlottyBot
  2. Selmo B on PlottyBot
  3. santry on Gondola PlottyBot v2
  4. santry on Built Me Another
  5. ben on Built Me Another

Archives

  • June 2026
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • May 2011
  • April 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • March 2010
  • December 2009
  • October 2009
  • September 2009
  • August 2009
  • June 2009
  • May 2009

Categories

  • 3D modeling / printing
  • aesthetics
  • agriculture
  • AI
  • all out geekery
  • apiculture
  • apple
  • Books
  • building
  • canning
  • crochet
  • electronics
  • foraging
  • homestead automation
  • hunting
  • I.T.
  • Lego / Duplo
  • life in the U.S.
  • maniacal paranoia
  • maple syrup
  • miscellaneous
  • nature encounters
  • old vinyls
  • organs
  • plots
  • plotters
  • poultry
  • preserving
  • self sustainability
  • solar power
  • specular holography
  • trip to a new life
  • unix / linux
  • video games
  • water
  • web development
  • web games
  • wood
Theme by Bloompixel. Proudly Powered by WordPress