app/controllers/application_controller.rb
# auth/refresh. Place this in a before_action in any controller needing access to the Bluebutton API.
auth/refresh. Place this in a before_action in any controller needing access to the Bluebutton API.
auth / refresh . Place this in a before_action in any controller needing access to the Bluebutton API .
def bluebutton_oauth_service_check
    if session[:bb_acc_token]
      @bluebutton_oauth_service = BluebuttonOauthService.new(session[:bb_acc_token],session[:bb_state])
      @bluebutton_oauth_service.restore_access_token
      if @bluebutton_oauth_service.expired?
        @bluebutton_oauth_service.refresh_access_token
        session[:bb_acc_token] = @bluebutton_oauth_service.bb_acc_token
      end	
    end
  end
def bluebutton_oauth_service_check if session [ :bb_acc_token ] @bluebutton_oauth_service = BluebuttonOauthService . new ( session [ :bb_acc_token ] , session [ :bb_state ] ) @bluebutton_oauth_service . restore_access_token if @bluebutton_oauth_service . expired? @bluebutton_oauth_service . refresh_access_token session [ :bb_acc_token ] = @bluebutton_oauth_service . bb_acc_token end end end
auth/refresh.
auth / refresh .
# Setup oauth2 client service # Save access token to session