oauth - 使用 GitLab 作为 Oauth 进行上传

标签 oauth gitlab upsource

我正在本地地址 http://192.168.0.18/ 上运行 GitLab 。 Upsource 正在 http://192.168.0.11/ 上运行.

我已将 Upsource 应用程序添加为 GitLab 上的管理员。我已经按照 GitLab 所说设置了客户端 ID 和 secret token 。授权设置为http://192.168.0.18/oauth/authorize ,代币到http://192.168.0.18/oauth/token和用户数据到 http://192.168.0.18/api/v4/user (根据GitLab documentation)。在字段映射中,我将用户 ID 设置为“id”,并将两个电子邮件设置为“email”。

然后,在Upsource的日志页面上,我有宣誓认证图标。单击后,GitLab 需要登录,并且用户必须为其帐户授权应用程序:

Authorization required

Authorize Upsource to use your account?

You are an admin, which means granting access to Upsource will allow them to interact with GitLab as an admin as well. Proceed with caution.

This application will be able to:

Access your API

Read user information

但是,点击授权按钮后,Upsource显示信息:身份验证失败。检查您的凭据并重试。。我哪里设置错了?字段映射?

最佳答案

哦,我找到答案了。正如经常发生的那样,我为此奋斗了好几个小时,就在我问了这个问题之后,我有了自己运行这个的想法。橡皮鸭方法,我猜...

正如我所怀疑的,问题出在字段映射中。

我查看了 Chrome 中的Network 选项卡,发现了以下响应:

http://192.168.0.11/hub/auth/login?response_type=token&client_id=[CLIENT_ID]&redirect_uri=[REDIRECT_URI]&message=hub-auth-failed&developer_message=getValueByPath%28json%2C+aut%E2%80%A6userIdPath%29%21%21.textValue%28%29+must+not+be+null

我已经手动完成了所有 Gitlab 工作流程,然后我可以登录 - 并且在运行 http://192.168.0.18/api/v4/user 之后端点,我有用户数据:

{"name":"username","username":"username","id":3,"state":"active","avatar_url":"http://www.gravatar.com/avatar/94232f2d1f8bb2fe940de439a4df1014?s=80&d=identicon","web_url":"http://debian/username","created_at":"2017-03-25T22:28:21.375Z","is_admin":true,"bio":null,"location":null,"skype":"","linkedin":"","twitter":"","website_url":"","organization":null,"last_sign_in_at":"2017-03-25T22:28:21.487Z","confirmed_at":"2017-03-25T22:28:21.376Z","email":"[email protected]","color_scheme_id":1,"projects_limit":100000,"current_sign_in_at":"2017-03-25T22:36:31.853Z","identities":[],"can_create_group":true,"can_create_project":true,"two_factor_enabled":false,"external":false}

问题出在设置 ID 字段名称上。正如我们在上面的 JSON 数据中看到的,id 字段应该映射到 name/username,而不是 id 本身。 进行此更改后,我可以成功登录 Upsource。

关于oauth - 使用 GitLab 作为 Oauth 进行上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43055607/

相关文章:

C# 应用程序 - 读取 Google 通讯录

Gitlab:如何允许用户在组命名空间下创建项目

websocket - 如何在 Traefik 中代理 WebSockets?

sonarqube - Upsource 和 SonarQube

docker - 如何将tracktrack,upsource和teamcity连接到集线器,这些集线器都在同一台机器上作为docker容器运行

iphone - 如何从 iOS 中的 Yahoo OAuth 集成获取访问 token ?

node.js - 为并行请求生成 oAuth nonce

oauth - 了解用户 ID 在 3 足 OAuth session 中的使用?

mysql - 无法使用 gitlab-ci.yml 连接到 MySql

linux - curl 正在从 gitlab 下载 html 而不是实际的 zip 文件