简体   繁体   English

在 api 中使用 Oauth2 发送不记名令牌

[英]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.

相关问题 使用Devise,Doorkeeper和OAuth2令牌进行API和应用程序身份验证 - API and Application authentication using Devise, Doorkeeper and OAuth2 token 我有一个带有 Doorkeeper OAuth2 client_credentials 的 Rails APP API。 如何在控制器中获取不记名令牌信息? - I have an Rails APP API with Doorkeeper OAuth2 client_credentials. How to get bearer token information within the controller? 如何使用Oauth2请求新鲜令牌 - How to request fresh token using Oauth2 结合使用Google OAuth2 API和Ruby on Rails - Using Google OAuth2 API with Ruby on Rails 无法获得Google AnalyticsAPI的oAuth2访问令牌 - Cannot get oAuth2 Access Token for Google Analytics API Oauth2流程使用Facebook uid请求令牌以获取凭据 - Oauth2 flow to request a token using Facebook uid for credentials Restforce Gem,Salesforce API重新调整OAuth2 :: Error Missing_OAuth_Token - Restforce Gem, Salesforce API retuning OAuth2::Error Missing_OAuth_Token 在 devise_token_auth 中成功 Oauth2 授权后如何将登录信息发送到前端? - How to send sign in info to frontend after successful Oauth2 authorization in devise_token_auth? OAuth使用者是否在每个请求中使用OAuth提供程序验证持有者令牌 - Does an OAuth Consumer validate a bearer token with the OAuth provider on each request Google Calendar Oauth2 API - Google Calendar Oauth2 API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM