Skip to content

Instantly share code, notes, and snippets.

@doccaico
Created October 17, 2020 07:34
Show Gist options
  • Select an option

  • Save doccaico/11e7b02328661f63117c1f467034e1f3 to your computer and use it in GitHub Desktop.

Select an option

Save doccaico/11e7b02328661f63117c1f467034e1f3 to your computer and use it in GitHub Desktop.
OAuth2 and Reddit API example using cURL
CLIENT_ID="****"
CLIENT_SECRET="****"
USER_NAME="****"
USER_PASSWORD="****"
curl -X POST -A "User agent" -d "grant_type=password&username=$USER_NAME&password=$USER_PASSWORD" --user "$CLIENT_ID:$CLIENT_SECRET" https://www.reddit.com/api/v1/access_token
# output
# {"access_token": "****", "token_type": "bearer", "expires_in":3600, "scope": "*"}
ACCESS_TOKEN="****"
curl -H "Authorization: bearer $ACCESS_TOKEN" -A "ChangeMeClient/0.1 by YourUsername" https://oauth.reddit.com/api/v1/me/
# output
#{"is_employee": *********
# ....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment