Code Monkey home page Code Monkey logo

reddit-orb's Introduction

Reddit Orb

CircleCI Build Status CircleCI Orb Version GitHub License CircleCI Community

Allows interaction with the Reddit API.

There are a number of required enviroment variables:

  • REDDIT_USER_AGENT
    • The user agent to make requests to the Reddit API with
  • CLIENT_ID
    • ID of a Reddit personnal use script
  • CLIENT_SECRET
    • Secret of the same Reddit personnal use script
  • REFRESH_TOKEN
    • Refresh token required to obtain new access tokens for your personnal use script

Obtaining Refresh Token

The REFRESH_TOKEN is the only piece of information that requires a number of steps to obtain - you can see the entire Reddit OAuth2 Flow if you wish.

Automated

If you don't wish to perform these steps manually, you can use reddit-oauth-helper, which automates many of the steps for you - leaving you with a JSON response:

{
  "access_token": "access-token-string",
  "token_type": "bearer",
  "expires_in": 3600,
  "refresh_token": "refresh-token-string",
  "scope": "string"
}

in which refresh-token-string would be what you would set as your REFRESH_TOKEN.

Manually

Visit this URL:

https://www.reddit.com/api/v1/authorize?client_id=CLIENT_ID&response_type=code&redirect_uri=URI&duration=permanent&scope=SCOPE_STRING

replacing CLIENT_ID and REDIRECT_URI with the listed values in your personal script settings, and SCOPE_STRING with a space-seperated list of scopes to grant.

You will then be redirected to your REDIRECT_URI with code=one-time-oauth-code in the URL, now you need to save the value of code - one-time-oauth-code in this example.


Next is to make a HTTP Basic authenticated POST request to this URL:

https://www.reddit.com/api/v1/access_token

with the data being

grant_type=authorization_code&code=one-time-oauth-code&redirect_uri=REDIRECT_URI

replacing one-time-oauth-code with the real value, and REDIRECT_URI with the same Redirect URI from before.

If you've been successful, you'll be presented with the same JSON object had you used the automated tool:

{
  "access_token": "access-token-string",
  "token_type": "bearer",
  "expires_in": 3600,
  "refresh_token": "refresh-token-string",
  "scope": "string"
}

Resources

CircleCI Orb Registry Page - The official registry page of this orb for all versions, executors, commands, and jobs described. CircleCI Orb Docs - Docs for using and creating CircleCI Orbs.

How to Contribute

We welcome issues to and pull requests against this repository!

How to Publish

  • Create and push a branch with your new features.
  • When ready to publish a new production version, create a Pull Request from fore feature branch to master.
  • The title of the pull request must contain a special semver tag: [semver:<segement>] where <segment> is replaced by one of the following values.
Increment Description
major Issue a 1.0.0 incremented release
minor Issue a x.1.0 incremented release
patch Issue a x.x.1 incremented release
skip Do not issue a release

Example: [semver:major]

  • Squash and merge. Ensure the semver tag is preserved and entered as a part of the commit message.
  • On merge, after manual approval, the orb will automatically be published to the Orb Registry.

For further questions/comments about this or other orbs, visit the Orb Category of CircleCI Discuss.

reddit-orb's People

Contributors

rascaltwo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.