https://github.com/sandysanthosh/springboot-oauth-github
Create a OAuth using GitHub. It will provide Client ID , Client Secret key then use in Spring Boot Application.
https://github.com/sandysanthosh/springboot-oauth-github
github java oauth2 springboot
Last synced: 3 months ago
JSON representation
Create a OAuth using GitHub. It will provide Client ID , Client Secret key then use in Spring Boot Application.
- Host: GitHub
- URL: https://github.com/sandysanthosh/springboot-oauth-github
- Owner: sandysanthosh
- Created: 2018-08-20T17:15:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-17T07:03:57.000Z (over 5 years ago)
- Last Synced: 2025-08-05T04:29:32.648Z (11 months ago)
- Topics: github, java, oauth2, springboot
- Language: Java
- Homepage: https://sandysanthosh.github.io/Springboot-OAuth-Github/
- Size: 54.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Springboot-OAuth-Github
Create a OAuth in github https://github.com/settings/developers it will provide Client ID , Client Secret then use in Spring Boot Application.
### OAuth in 3 steps:
### steps 1 Pom.xml:
org.springframework.boot
spring-boot-starter-oauth2-client
#### steps 2 main.java:
```
package com.example.demo;
import java.security.Principal;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
@EnableOAuth2Sso
public class Application {
@RequestMapping
public String getName(Principal name)
{
return "id" + name.getName() + "welcome Oauth";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
```
### steps 3 Application.yml:
```
security:
oauth2:
client:
clientId: a48f56f893775afb1912
clientSecret: c91036f105c04d0666655f411f716c43b606d373
accessTokenUri: https://github.com/login/oauth/access_token
userAuthorizationUri: https://github.com/login/oauth/authorize
clientAuthenticationScheme: form
resource:
user-info-uri: https://api.github.com/user
prefer-token-info: false
```
### Test the links:
http://localhost:8080/
