-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #574 from sabeechen/dev
Merge release 0.106.1
- Loading branch information
Showing
36 changed files
with
944 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,45 @@ | ||
# Notice 3/16/2022 | ||
Because of [recent changes Google has made](https://developers.googleblog.com/2022/02/making-oauth-flows-safer.html#dates-oob) to its authentication backend the below instructions no longer work. I'm aware of the issue, have a workaround selected and am working toward implementing it. In the meantime using your own credentials is not available and the only way to authenticate the addon is using the big "Authenticate with Google Drive" button which sends credentials through the habackup.io domain. | ||
|
||
|
||
# Local Authentication | ||
You've arrived here because you'd like to use your own client ID and client secret to authenticate the add-on with Google Drive. I'll caution that this is a very detailed and complicated process geared more toward developers than end users, so if you'd like to do it the easy way, go back to your add-on (typically http://homeassistant.local:8123/hassio/ingress/hassio_google_drive_backup) and click the "Authenticate with Google Drive" button. These instructions will have you create a project on Google's Developer Cloud console, generate your own credentials, and use them to authenticate with Google Drive. You can expect this to take about 15 minutes. Typically this is what would be done by a developer when releasing a project that serveral users would use, but in this case you will be the only user. This workflow is for you if: | ||
* You'd like to avoid having your account's credentials go through a server maintained by me. The typical authentication workflow never sees your Google account password, but it does recieve a token from Google that, if I were malicious, I could use to see the backups you've uploaded to Google Drive. I don't store this token anywhere and instead just pass it back to you, but becase of how Google oauth tokens are generated there is no way you could verify that. I tip my tinfoil hat to yours and respect your desire to protect your personal information :) | ||
* The typical authentication flow didn't work. This may be because of a bug, or because the server I set up to handle it is down or broken. Its just me back here providing this as a free service to the community, so applogogies if things fall into disrepair. | ||
|
||
These instructions are current as of March 2021. If you do this and notice they're out of date, Please file an issue on this project's issue page so I can be made aware of it. Thanks! | ||
|
||
## Step 1 - Create a Google Cloud Project | ||
* Go to http://console.developers.google.com and log in with your Google account. | ||
* Click "Select Project" on the top left. | ||
* Click "New Project" to create a project. | ||
* Give the project any name you like, and click "Create Project". Don't worry about billing or location information, you won't be charged for anything we're doing here. | ||
![](images/step1.png) | ||
|
||
## Step 2 - Enable the Drive API | ||
With your project now created: | ||
* Go to https://console.developers.google.com/apis/library | ||
* Search for "Google Drive API", and click "Enable". This is necessary because the "Project" you're creating will use the [Google Drive API](https://developers.google.com/drive/api/v3/reference). | ||
|
||
## Step 3 - Create a Consent Screen | ||
Before creating credentials, you'll need to create a consent screen. Normally this is what people would see when they request to allow your new application to access their Google Drive, but because you're creating it just for yourself this is basically just a necessary formality. | ||
* Go back to http://console.developers.google.com and ensure the project name you created earlier is displayed in the upper left. | ||
* In the menu on the upper left, click **APIs & Services** then *OAuth Consent Screen*. | ||
* Select *External* for the user type and then click "Create". Even though you're probably making these credentials with the same account you'll be using to authenticate the addon, you'll still be considered an *External* user. | ||
* On the next screen "App Information", fill in all the required fields, *App Name*, *Support Email*, and *Developer Email*. Then click Continue. What you enter here doesn't really matter, but a good App Name is something that will make you laugh if you ever have to see this again, like "Buy the name-brand SD Card this time, maybe?" | ||
* On the next screen, click **Add OR Remove Scopes**. In the dialog that pops up check the box for "../auth/drive.file" and then click "Add". You might have to search for "drive.file" to make it show up. This part is very important since it gives the credentials we're about to create permission to see files in Google Drive. If you don't see this in the dialog that comes up, make sure you did step 2. | ||
* You can leave the rest of this form blank, just click **Save** or **Continue** for any other screens. | ||
* Once its created, either click **Go Back to Dashboard** or click **OAuth Consent Screen** on the left. Under **Publishing status** click **Publish App** and then **Confirm**. This dialog will warn that the app will be available to all users, but in our case it will still only be you if you keep the credentials you create later just to yourself. This step is necessary because "Testing" credentials would require you to manually re-authorize the addon ever 7 days, which is a pain. | ||
|
||
## Step 4 - Create Credentials | ||
Now you've set up everything necessary to actually create credentials. | ||
* From http://console.developers.google.com, click **APIs & Services** then **Credentials** on the left. | ||
* Click **+ Create Credentials** at the top of the page. | ||
* Select "OAuth client ID" form the drop down. | ||
This should have opened a dialog titled "Create OAuth client ID". | ||
![](images/step3-b.png) | ||
* Select **Desktop app** for **Application Type** | ||
* Give the credentials a **Name**, anything will do. | ||
![](images/step4.png) | ||
* Click "Create" | ||
|
||
|
||
## Step 5 - Copy your credentials | ||
This should have opened a new dialog with your generated client ID and client secret. Take these back to the Add-on, and paste them into the appropriate fields of the add-on web-UI, and follow the instructions from there. | ||
![](images/step5.png) | ||
# Using Custom/Personal Google Credentials | ||
You've arrived here because you'd like to use your own client ID and client secret to authenticate the add-on with Google Drive. I'll caution that this is a very detailed and complicated process geared more toward developers than end users, so if you'd like to do it the easy way, go back to your add-on (typically http://homeassistant.local:8123/hassio/ingress/hassio_google_drive_backup) and click the "Authenticate with Google Drive" button. These instructions will have you create a project on Google's Developer Cloud console, generate your own credentials, and use them to authenticate with Google Drive. You can expect this to take about 15 minutes. Typically this is what would be done by a developer when releasing a project that serveral users would use, but in this case you will be the only user. This workflow is for you if: | ||
* You'd like to avoid having your account's credentials go through a server maintained by the developer of this addon. The typical authentication workflow never sees your Google account password, but it does recieve a token from Google that, if I were malicious, I could use to see the backups you've uploaded to Google Drive. I don't store this token anywhere and instead just pass it back to you, but because of how Google OAuth tokens are generated there is no way you could verify that. I tip my tinfoil hat to yours and respect your desire to protect your personal information :) | ||
* The typical authentication flow didn't work. This may be because of a bug, or because the server I set up to handle it is down or broken. Its just me back here providing this as a free service to the community, so applogogies if things fall into disrepair. | ||
|
||
These instructions are current as of March 2022. If you do this and notice they're out of date, Please file an issue on this project's issue page so I can be made aware of it. Thanks! | ||
## Step 0 - Check addon version | ||
You must be runnign version 0.106.1 or greater of the add-on for this to work. In Feb 2022 Google changed how some of their authentication APIs work which broke the way the addon did it before that version | ||
## Step 1 - Create a Google Cloud Project | ||
* Go to http://console.developers.google.com and log in with your Google account. | ||
* Click "Select Project" on the top left. | ||
* Click "New Project" to create a project. | ||
* Give the project any name you like, and click "Create Project". Don't worry about billing or location information, you won't be charged for anything we're doing here. | ||
![](images/step1.png) | ||
|
||
## Step 2 - Enable the Drive API | ||
With your project now created: | ||
* Go to https://console.developers.google.com/apis/library | ||
* Search for "Google Drive API", and click "Enable". This is necessary because the "Project" you're creating will use the [Google Drive API](https://developers.google.com/drive/api/v3/reference). | ||
|
||
## Step 3 - Create a Consent Screen | ||
Before creating credentials, you'll need to create a consent screen. Normally this is what people would see when they request to allow your new application to access their Google Drive, but because you're creating it just for yourself this is basically just a necessary formality. | ||
* Go back to http://console.developers.google.com and ensure the project name you created earlier is displayed in the upper left. | ||
* In the menu on the upper left, click **Enabled APIs & Services** then *OAuth Consent Screen*. | ||
* Select *External* for the user type and then click "Create". Even though you're probably making these credentials with the same account you'll be using to authenticate the addon, you'll still be considered an *External* user. | ||
* On the next screen "App Information", fill in all the required fields, *App Name*, *Support Email*, and *Developer Email*. Then click "Save & Continue". What you enter here doesn't really matter, but a good App Name is something that will make you laugh if you ever have to see this again, like "Buy the name-brand SD Card this time, maybe?" | ||
* On the next screen, click **Add OR Remove Scopes**. In the dialog that pops up check the box for "../auth/drive.file" and then click "Update". You might have to search for "drive.file" to make it show up. This part is very important since it gives the credentials we're about to create permission to see files in Google Drive. If you don't see this in the dialog that comes up, make sure you did step 2. | ||
* You can leave the rest of this form blank, just click **Save** or **Continue** for any other screens. | ||
* Once its created, either click **Go Back to Dashboard** or click **OAuth Consent Screen** on the left. Under **Publishing status** click **Publish App** and then **Confirm**. This dialog will warn that the app will be available to all users, but in our case it will still only be you if you keep the credentials you create later just to yourself. This step is necessary because "Testing" credentials would require you to manually re-authorize the addon ever 7 days, which is a pain. | ||
|
||
## Step 4 - Create Credentials | ||
Now you've set up everything necessary to actually create credentials. | ||
* From http://console.developers.google.com, click **Enabled APIs & Services** then **Credentials** on the left. | ||
* Click **+ Create Credentials** at the top of the page. | ||
* Select "OAuth client ID" form the drop down. | ||
This should have opened a dialog titled "Create OAuth client ID". | ||
* Select **TVs and Limited Input Devices** for **Application Type**. Home Assistant might not seem like a "Limited Input Device" but is is necessary because its the only OAuth authentication method Google provides that doesn't require you to maintain a public SSL encrpted web service. | ||
* Give the credentials a **Name**, anything will do and it doesn't matter. | ||
![](images/step4.png) | ||
* Click "Create" | ||
|
||
|
||
## Step 5 - Copy your credentials | ||
This should have opened a new dialog with your generated client ID and client secret. Take these back to the Add-on, and paste them into the appropriate fields of the add-on web-UI, and follow the instructions from there. | ||
![](images/step5.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
hassio-google-drive-backup/backup/config/durationassecondsvalidator.py
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
hassio-google-drive-backup/backup/config/durationasstringvalidator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from datetime import timedelta | ||
from .durationparser import DurationParser | ||
from .validator import Validator | ||
|
||
|
||
class DurationAsStringValidator(Validator): | ||
def __init__(self, name, minimum=None, maximum=None, base_seconds=1, default_as_empty=None): | ||
super().__init__(name) | ||
self.min = minimum | ||
self.max = maximum | ||
self.base_seconds = base_seconds | ||
self.default_as_empty = default_as_empty | ||
|
||
def validate(self, value): | ||
if value is None or (type(value) == str and len(value) == 0): | ||
return None | ||
try: | ||
if type(value) == str: | ||
if self.default_as_empty is not None and value == "": | ||
value = self.default_as_empty | ||
else: | ||
value = DurationParser().parse(value).total_seconds() / self.base_seconds | ||
value = float(value) | ||
except ValueError: | ||
self.raiseForValue(value) | ||
|
||
if self.max is not None and value > self.max: | ||
self.raiseForValue(value) | ||
if self.min is not None and value < self.min: | ||
self.raiseForValue(value) | ||
return value | ||
|
||
def formatForUi(self, value): | ||
if self.default_as_empty is not None and value == self.default_as_empty: | ||
return "" | ||
else: | ||
return DurationParser().format(timedelta(seconds=value * self.base_seconds)) |
Oops, something went wrong.