Created
October 17, 2020 07:34
-
-
Save doccaico/11e7b02328661f63117c1f467034e1f3 to your computer and use it in GitHub Desktop.
OAuth2 and Reddit API example using cURL
This file contains hidden or 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
| 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": "*"} |
This file contains hidden or 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
| 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