From a36c15fe88a5f0ea9ceca97145bf0204c969fac8 Mon Sep 17 00:00:00 2001 From: FoxDeploy Date: Thu, 17 Sep 2015 14:51:23 -0400 Subject: [PATCH] Fixed an error I caused, added better help --- PSReddit.psd1 | 3 +-- PSReddit.psm1 | 17 ++++++++++++---- Public/Connect-RedditAccount.ps1 | 34 +++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/PSReddit.psd1 b/PSReddit.psd1 index 0681297..6f5b77e 100644 --- a/PSReddit.psd1 +++ b/PSReddit.psd1 @@ -14,8 +14,7 @@ ModuleVersion = '1.0' GUID = '3dede632-fde4-4cc6-85df-9f5cfd6cd124' # Author of this module -Author = 'Tobin Jones' -Author = 'Stephen Owen' +Author = 'Tobin Jones', 'Stephen Owen' # Copyright statement for this module Copyright = 'Licensed under the MIT license' diff --git a/PSReddit.psm1 b/PSReddit.psm1 index c83a535..30ebdc1 100644 --- a/PSReddit.psm1 +++ b/PSReddit.psm1 @@ -27,15 +27,24 @@ { #Import the config $password = Import-Clixml -Path $configDir -ErrorAction STOP | ConvertTo-SecureString - $refreshToken = Import-Clixml -Path $refreshToken -ErrorAction STOP | ConvertTo-SecureString + } catch { Write-Warning "Corrupt Password file found, rerun with -Force to fix this" - BREAK + } + + Try + { + #Import the config + + $refreshToken = Import-Clixml -Path $refreshToken -ErrorAction STOP | ConvertTo-SecureString + } + catch { + Write-Warning "Corrupt refresh token file found, rerun with -Force to fix this" } - Get-DecryptedValue -inputObj $password -name PSReddit_accessToken - Get-DecryptedValue -inputObj $refreshToken -name PSReddit_refreshToken + if ($password){Get-DecryptedValue -inputObj $password -name PSReddit_accessToken} + if($refreshToken){Get-DecryptedValue -inputObj $refreshToken -name PSReddit_refreshToken} diff --git a/Public/Connect-RedditAccount.ps1 b/Public/Connect-RedditAccount.ps1 index c4c4004..e7368c9 100644 --- a/Public/Connect-RedditAccount.ps1 +++ b/Public/Connect-RedditAccount.ps1 @@ -1,4 +1,36 @@ -Function Connect-RedditAccount { +<# +.Synopsis + Use this cmdlet to connect to your Reddit account from PowerShell +.DESCRIPTION + Use this cmdlet to connect to your Reddit account from PowerShell.You'll first need to register for an Register for a Reddit API account here, https://www.reddit.com/prefs/apps, and choose a Script based Application. + + Make note of your ClientSecret, ClientID and RedirectURI (which can be anything). This cmdlet displays a login window to allow a user to provision access to their account by means of oAuth. + + The permissions requested are: identity, history, mysubreddits, read, report, save, submit +.EXAMPLE + Connect-RedditAccount -ClientID $ClientID -ClientSecret $ClientSecret -RedirectURI $RedirectURI +.EXAMPLE + Another example of how to use this cmdlet +.INPUTS + Inputs to this cmdlet (if any) +.OUTPUTS + Output from this cmdlet (if any) +.NOTES + You'll first need to register for an Register for a Reddit API account here, https://www.reddit.com/prefs/apps, and choose a Script based Application. Make note of your ClientSecret, ClientID and RedirectURI (which can be anything). +.COMPONENT + The component this cmdlet belongs to +.ROLE + The role this cmdlet belongs to +.FUNCTIONALITY + The functionality that best describes this cmdlet +.LINK + https://www.reddit.com/dev/api + For Reference for the API + https://github.com/1RedOne/PSReddit/ + The project homepage on GitHub + +#> +Function Connect-RedditAccount { [CmdletBinding()] param( $ClientSecret,