简体   繁体   中英

Using Oauth2 to send bearer token in api

I have an api and i have gained access to the bearer token by sending username and password. I need to use the token to then send send another request using Oauth2 gem(ruby). HI have the endpoint

below is an example of something i think it may look like. I don't know the syntax or how to send this token to the url

it would be great if someone could give me an example of how to set up the method. Where to plug in the bearer token that i have saved to an instance variable, etc.

req = Net::HTTP::Get.new(url.to_s)

You need to add Authorization to the header, where the value is the bearer token. A header can be set like so req["header_name"] = header

You seem fairly new to this, I suggest you use RestClient instead https://github.com/rest-client/rest-client . Much more user friendly and the documentation is easier to read.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM