使用OAuth2.0 Rails进行Eventbrite身份验证 [英] Eventbrite authentication using OAuth2.0 Rails

查看:120
本文介绍了使用OAuth2.0 Rails进行Eventbrite身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应用程序,试图通过eventbrite对用户进行身份验证.参考 doc ,我将javascript包含在我的应用程序,它会在我的应用程序中生成一个 CONNECT EVENTBRITE 链接.

Iam creating an application where I am trying to authentivate a user with eventbrite. With reference of doc I include the javascript in my application and it generates a CONNECT WITH EVENTBRITE link in my app.

当我单击此按钮时,它将带我到URL:

When I click this button It takes me to the url:

https://www.eventbrite.com/oauth/authorize? response_type = token& client_id = xxxxxxxxxxxx

(这里的客户ID是我的应用程序的eventbrite应用程序密钥.)

(Here client id is the eventbrite app key of my application.)

当用户允许应用程序访问evenbrite帐户时,它将使用以下URL将我重定向到我的应用程序:

When the user ALLOWS the application to access the evenbrite account it redirects me to my application with the following url:

http://localhost:3000/#token_type=Bearer&access_token=yyyyyyyyyyyyyyyyyyyy

我希望网址中的访问令牌访问用户的信息.我尝试使用 URI 解析网址.但是我没有找到这样做的最佳方法.有人可以告诉我一个很好的解决方案,从上述URL中提取 access_token .

I want the access token in the url to access a user's information. I tried to parse url using URI. But I didn't find it the best way to do so.. Can anyone please tell me a good solution to extract the access_token from the above url.

推荐答案

对于服务器端OAuth2.0 ,我将在您的初始URL中使用response_type = code:

For server-side OAuth2.0, I'd use response_type=code in your initial URL:

https://www.eventbrite.com/oauth/authorize?response_type=code&client_id=xxxxxxxxxxxx

要找到access_code,请从查询字符串中获取"code"参数:

To find the access_code, grab the 'code' parameter from the querystring:

require 'uri'
uri = URI("http://localhost:3000/?code=XVYMCZOHM4D2GBXTJZG6")
access_code = uri.query.split('&')[0].split('=')[1]

下一步是对 https://www.eventbrite.com/进行服务器端POST. oauth/token 以及临时访问代码,您的client_secret和其他一些详细信息(此处概述:

The next step is to make a server-side POST to https://www.eventbrite.com/oauth/token with the temporary access_code, your client_secret, and a few other details (outlined here: http://developer.eventbrite.com/doc/authentication/oauth2/)

code=THE_USERS_AUTH_CODE&client_secret=YOUR_CLIENT_SECRET&client_id=YOUR_API_KEY&grant_type=authorization_code

用户的access_token应该在POST响应中可用.

The user's access_token should be available in the POST response.

这篇关于使用OAuth2.0 Rails进行Eventbrite身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆