我正在本地地址 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
选项卡,发现了以下响应:
我已经手动完成了所有 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/