Quick use (take QQ as an example):
1. If it is the first time to use it, you need to apply for a developer on the “QQ Internet Platform”, create an application and copy three information: App ID, App Key and website callback domain
2. Integrate JustAuth
Add dependencies
<dependency><groupId>me.zhyd.oauth</groupId><artifactId>JustAuth</artifactId><version>${latest.version}</version></dependency>
- Create a request and add the three information from the first step
AuthRequest authRequest = new AuthQqRequest(AuthConfig.builder().clientId("App ID").clientSecret("App Key").redirectUri("网站回调域").build());
- Generate an authorization address
This link can be redirected directly in the background, or it can be returned to the frontend to jump String authorizeUrl = authRequest.authorize(AuthStateUtils.createState());
Or generate an authorization page
authRequest.authorize(“state”); auth_code After version 1.8.0, you can use the AuthCallback class as a parameter of the callback interface// Note: By default, JustAuth saves the state for 3 minutes, and if it is not used within 3 minutes, the expired stateauthRequest.login(callback) will be automatically cleared;
The JustAuth team is still connecting to the authorized login of other platforms, interested students can pay attention to it.