ruby on rails - OmniAuth OAuth2 how to access to a strategy -> client? so that I can refresh token? -


background

i have omniauth-oauth2 subclass strategy working on rails app. when refresh access_token, see need create oauth2::accesstoken. create it, seems requires oauth2::client think can obtain "omniauth-oauth2 subclass strategy."

found solution refresh token using omniauth-oauth2 in rails application how solved obtain strategy

# initial param:nil meant rack object, since  # don't use here, give nil strategy = omniauth::strategies::your_provider.new nil, client_id, client_secret client = strategy.client  your_expired_at_from_your_provider = time.now.to_i  hash = {   access_token: "your access_token provider",   refresh_token: "your refresh_token provider",   expires_at: your_expired_at_from_your_provider, } access_token_object = oauth2::accesstoken.from_hash(client, hash) access_token_object.refresh! 

https://github.com/omniauth/omniauth/blob/v1.6.1/lib/omniauth/strategy.rb#l132 https://github.com/intridea/omniauth-oauth2/blob/v1.4.0/lib/omniauth/strategies/oauth2.rb#l35 https://github.com/intridea/oauth2/blob/master/lib/oauth2/access_token.rb#l12 https://github.com/intridea/oauth2/blob/v1.4.0/lib/oauth2/access_token.rb#l82

problem

what don't understand is, looks bit of hacky ways create strategy giving nil first argument.

"omniauth-oauth2 subclass strategy" in rack (like image below), thinking there way access strategy rack middleware, somewhere?

question

is creating strategy above way refresh token?
strategy -> client -> access_token_object -> refresh!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -