[英]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.我有一个 api 并且我通过发送用户名和密码获得了对不记名令牌的访问权限。 I need to use the token to then send send another request using Oauth2 gem(ruby).
我需要使用令牌然后使用 Oauth2 gem(ruby) 发送另一个请求。 HI have the endpoint
HI有端点
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
我不知道语法或如何将此令牌发送到 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.您需要将
Authorization
添加到 header,其中 value 是不记名令牌。 A header can be set like so req["header_name"] = header
A header 可以这样设置
req["header_name"] = header
You seem fairly new to this, I suggest you use RestClient instead https://github.com/rest-client/rest-client .您对此似乎很陌生,我建议您使用 RestClient 而不是https://github.com/rest-client/rest-client 。 Much more user friendly and the documentation is easier to read.
更加用户友好,文档更易于阅读。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.