ruby - paste and use a oauth2 access token -


i have application using ruby , sinatra. want able paste token in format:

{"access_token":"token...uwd--of0iknjr8aew3os9zp2rith3fdsf2wk","token_type":"bearer","expires_in":3600,"created":1415727521} 

into text-area , use it. problem is, pasted token in string format. have tried converting hash , json format ain't working still. here code:

post '/tokenize'   got_token = params[:token] # pasted token   token_hash = json.parse(got_token) #i not sure if did correctly.but producing hash.   token = token_hash.to_json # producing token in json format original token pasted.   get_contacts(json.parse(token)) # calling function should use token. giving error since not valid oauth token.  redirect ("/tokenize/finish") end 

error: producing error because token not valid oauth token. please tell me how make token valid , usable.

you can manually instantiate token class oauth2::accesstoken params have collected full definition of constructour can find here.

but need oauth2 client using manually instantiated.

for example:

client = oauth2::client.new('client_id', 'client_secret', :site => 'https://example.org')  token = oauth2::accesstoken.new(client, collected_token, collected_opts)  response = token.get('/api/resource', :params => { 'query_foo' => 'bar' }) 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -