Here's an approach which doesn't depend on any third party libraries. I.e. it's in terms of pure PowerShell.

Let's assume you're keeping your reddit credentials, reddit app client ID and reddit app client secret in files:

$username = Get-Content $env:APPDATA\reddit-username $password = Get-Content $env:APPDATA\reddit-password $app_client_id = Get-Content $env:APPDATA\reddit-app-client-id $app_client_secret = Get-Content $env:APPDATA\reddit-app-client-secret

(See this page for information about getting a reddit client ID.)

Retrieve an access token:

$result_access_token = Invoke-RestMethod -Uri 'https://www.reddit.com/api/v1/access_token' ` -Method Post ` -Headers @{ Authorization = ('Basic {0}' -f ( [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes( "${app_client_id}:${app_client_secret}")))) } ` -Body @{ grant_type = 'password' username = $username password = $password }

Let's extract the token from the result and assign it to a variable:

$token = $result_access_token.access_token

Now let's get the current hot links on /r/programming :

$result_listing = Invoke-RestMethod -Uri 'https://oauth.reddit.com/r/programming/hot' -Headers @{ Authorization = "bearer $token" }

Show the links:

$result_listing.data.children | ForEach-Object data | Select-Object score, subreddit, title, url

Example output: