Bad URI with Ruby

I am making oauth call in facebook api to get access_token

def access_token
  token_uri = URI("https://graph.facebook.com/oauth/access_token?client_id=#{CLIENT_ID}&client_secret=#{CLIENT_SECRET}&grant_type=client_credentials")
  token_response = HTTParty.get(token_uri)
  Rails.logger.info(token_response)
  return token_response
end

I get a response and an access_token is generated, let's say it

access_token=123456789|abcdefghijk

but when I try to use this token

def get_feed
  fb_access_token = access_token
 uri = URI("https://graph.facebook.com/#{VANDALS_ID}/posts/?#{fb_access_token}")

end

I get an error

URI::InvalidURIError: bad URI(is not URI?)

and the generated uri stops at | even though after the completion of work on the channel more characters appear to complete my access

https://graph.facebook.com/id-here/posts/?access_token=123456789|

how to get an accessible access token available in my URI

Any help appreciated

thank

+4
source share
1 answer

, , , | URI, . URI :

uri = URI(URI.escape "https://graph.facebook.com/#{VANDALS_ID}/posts/?#{fb_access_token}")
uri.to_s     #=> https://graph.facebook.com/id-here/posts/?access_token=123456789%7Cabcdefghijk

url, , .

+7

Source: https://habr.com/ru/post/1538766/


All Articles