从头开始执行Oauth2

问题描述 投票:1回答:2

出于研究目的,我想从头开始实现Oauth2协议。创建具有客户端ID和客户端密钥的应用程序后,我将遵循Github指南。

这两个信息源非常简单,分别是:

https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/https://gist.github.com/technoweenie/419219

特别是,我从粘贴到浏览器的第一步开始:

https://github.com/login/oauth/authorize?client_id=&redirect_uri=http://localhost:8080/auth/temp&scope=user&state=&allow_signup=true

我有一个Spring应用程序在端口8080上侦听(我不想使用Spring Security,因为我想从头开始实现该协议),并且暴露了以下工作端点:

@RequestMapping("/auth/temp")
public String redirectAuth(HttpServletRequest request) {
    //TODO implement next steps
    return "here we are!";
}

但是当我转到github链接时,出现404 not found错误,因为我的本地主机应用程序将不存在。

[我希望官方指南缺少一些强制性信息,例如我的应用程序必须公开的其他一些端点才能被查询,例如,有关客户端机密的信息。

所以,我想念什么?

oauth-2.0 jwt openid github-api
2个回答
0
投票

Github仅支持身份验证代码oauth 2流。仔细阅读可能会有所帮助。

我有一个博客和一个有关身份验证代码流程的视频,可能会有所帮助。

免责声明:我在Ping身份工作并创建了它们,但我认为即使对于您的学习目的,它们也会有所帮助。

https://developer.pingidentity.com/en/blog/posts/2019/what-are-oauth-2-0-grant-types-part-1-authorization-code-flow.html

https://youtu.be/eg7I8x-u0sc


0
投票

您尚未在授权URL中包含client_id

https://github.com/login/oauth/authorizeclient_id =&redirect_uri = http://localhost:8080/auth/temp&scope=user&state=&allow_signup=true

授权服务器(GitHub)需要此值来标识您已注册的客户端。

© www.soinside.com 2019 - 2024. All rights reserved.