app/controllers/api/v1/users_controller.rb
def link_oauth
    # Reddit requires state token for droplet's use to further verify user
    state_token = Sysrandom.urlsafe_base64(32)
      current_user.update(state_token: state_token)

      # creating hash to pass to frontend for OAuth redirect
      @redirect_info = {
        query_params: {
          client_id: ENV['REDDIT_KEY'],
          response_type: "code",
          redirect_uri: ENV['REDIRECT_URI'],
          duration: "permanent",
          state: state_token,
          scope: "identity edit read save submit subscribe vote history"
        }.to_query,
       url: "https://www.reddit.com/api/v1/authorize?"
     }
     render json: @redirect_info
   end
# Reddit requires a user to be redirected to their page for approval, creating hash to pass to front end for routing
Reddit requires a user to be redirected to their page for approval, creating hash to pass to front end for routing
Reddit requires a user to be redirected to their page for approval creating hash to pass to front end for routing
def link_oauth
    state_token = Sysrandom.urlsafe_base64(32)
      current_user.update(state_token: state_token)
      @redirect_info = {
        query_params: {
          client_id: ENV['REDDIT_KEY'],
          response_type: "code",
          redirect_uri: ENV['REDIRECT_URI'],
          duration: "permanent",
          state: state_token,
          scope: "identity edit read save submit subscribe vote history"
        }.to_query,
       url: "https://www.reddit.com/api/v1/authorize?"
     }
     render json: @redirect_info
   end
def link_oauth state_token = Sysrandom . urlsafe_base64 ( 32 ) current_user . update ( state_token : state_token ) @redirect_info = { query_params : { client_id : ENV [ 'REDDIT_KEY' ] , response_type : "code" , redirect_uri : ENV [ 'REDIRECT_URI' ] , duration : "permanent" , state : state_token , scope : "identity edit read save submit subscribe vote history" } . to_query , url : "https://www.reddit.com/api/v1/authorize?" } render json : @redirect_info end
Reddit requires a user to be redirected to their page for approval, creating hash to pass to front end for routing
Reddit requires a user to be redirected to their page for approval creating hash to pass to front end for routing
# Reddit requires state token for droplet's use to further verify user # creating hash to pass to frontend for OAuth redirect