Skip to content

Commit 06d17f3

Browse files
authored
Change to Google API auth-scopes (#42)
* Change Google client id and secret to PSBloggerAPI * Don't include trashed files in Google Drive queries * rev version to 0.3.0 * update meta in powershell module * modify publish workflow to use secrets
1 parent 330609e commit 06d17f3

5 files changed

Lines changed: 24 additions & 11 deletions

File tree

.github/workflows/publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ jobs:
186186
if ($testResults.FailedCount -gt 0) {
187187
throw "Tests failed. Cannot publish to PowerShell Gallery."
188188
}
189+
190+
- name: Inject Values into Module
191+
shell: pwsh
192+
env:
193+
CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
194+
CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
195+
run: |
196+
$file = "./src/public/Initialize-Blogger.ps1"
197+
$content = Get-Content $file -Raw
198+
$content = $content -replace "<<CLIENT_ID>>", $env:CLIENT_ID
199+
$content = $content -replace "<<CLIENT_SECRET>>", $env:CLIENT_SECRET
200+
$content | Set-Content -Path $file -Force
189201
190202
- name: Publish to PowerShell Gallery
191203
shell: pwsh

src/PSBlogger.psd1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
RootModule = 'PSBlogger.psm1'
66

77
# Version number of this module.
8-
ModuleVersion = '0.2.0'
8+
ModuleVersion = '0.3.0'
99

1010
# Supported PSEditions
1111
# CompatiblePSEditions = @()
@@ -20,7 +20,7 @@ Author = 'Bryan Cook'
2020
CompanyName = 'Bryan Cook'
2121

2222
# Copyright statement for this module
23-
Copyright = '#169; me'
23+
# Copyright = '#169; me'
2424

2525
# Description of the functionality provided by this module
2626
Description = 'Module to publish markdown files to Blogger'
@@ -97,16 +97,16 @@ PrivateData = @{
9797
Tags = 'blogger','markdown','pandoc'
9898

9999
# A URL to the license for this module.
100-
#LicenseUri = ''
100+
LicenseUri = 'https://github.com/bryanbcook/PSBlogger?tab=MIT-1-ov-file#readme'
101101

102102
# A URL to the main website for this project.
103-
ProjectUri = 'http://www.bryancook.net/'
103+
ProjectUri = 'https://github.com/bryanbcook/PSBlogger'
104104

105105
# A URL to an icon representing this module.
106106
#IconUri = ''
107107

108108
# ReleaseNotes of this module
109-
#ReleaseNotes = ''
109+
ReleaseNotes = 'https://github.com/bryanbcook/PSBlogger/releases'
110110
# Prerelease string of this module
111111
# Prerelease = ''
112112

src/public/Add-GoogleDriveFile.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Add-GoogleDriveFile {
3030
[string]$FileName,
3131

3232
[Parameter()]
33-
[string]$TargetFolderName = "Open Live Writer",
33+
[string]$TargetFolderName = "PSBlogger",
3434

3535
[Parameter()]
3636
[switch]$Force

src/public/Get-GoogleDriveItems.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ function Get-GoogleDriveItems {
5353
$q += "'$ParentId' in parents"
5454
}
5555

56+
$q += "trashed=false" # Exclude trashed items
57+
5658
$queryArgs = @{
5759
q = [System.Web.HttpUtility]::UrlEncode($q -join ' and ')
5860
pageSize = 40
59-
}
61+
}
6062

6163
do {
6264

src/public/Initialize-Blogger.ps1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Initiate a login flow with Google
2525
Function Initialize-Blogger {
2626
Param(
2727
[Parameter(HelpMessage = "Google API ClientId")]
28-
[string]$clientId = "284606892422-ribvo7oodlbtd70e8onn8rg4hm58mluj.apps.googleusercontent.com",
28+
[string]$clientId = "<<CLIENT_ID>>",
2929

3030
[Parameter(HelpMessage = "Google API Client Secret")]
31-
[string]$clientSecret = "PUK0j9ig-GHcSByQao2i1aIa",
31+
[string]$clientSecret = "<<CLIENT_SECRET>>",
3232

3333
[Parameter(HelpMessage = "Redirect Uri specified in Google API Consent Form")]
3434
[string]$redirectUri = "http://localhost/oauth2callback"
@@ -41,8 +41,7 @@ Function Initialize-Blogger {
4141
# specify the scopes we want in our auth token
4242
$scope = @(
4343
"https://www.googleapis.com/auth/blogger"
44-
#"https://www.googleapis.com/auth/drive.file" # TODO: fix
45-
"https://www.googleapis.com/auth/drive"
44+
"https://www.googleapis.com/auth/drive.file"
4645

4746
) -join " "
4847

0 commit comments

Comments
 (0)