SpringBoot+Vue implements third-party GitHub login (1)

1. GitHub login introduction (test website: address )

       Third-party websites access the GitHub open platform mainly through the use of "GitHub Login". "GitHub Login" is a service provided by the GitHub platform to third-party websites. "

  At the same time, based on the binding information provided by users, the third-party website uses Gitee's huge user base to further spread the information of the website through friendship, increasing the number of visits and users of the website.

  OAuth : OAuth (Open Authorization) is an open standard that allows users to authorize third-party websites to access their information stored on another service provider, without the need to provide usernames and passwords to third-party websites or share all content of their data .

  The OAuth protocol provides a safe, open and simple standard for authorization of user resources.

  The difference from the previous authorization method is that the OAUTH authorization will not allow the third party to touch the user's account information (such as user name and password), that is, the third party can apply to obtain the user's resources without using the user's user name and password. Authorization, so OAUTH is secure.

  OAuth is short for Open Authorization, and the current version is version 2.0.  OAuth 2.0 — OAuth

2. Become a developer

     Developers can access the Gitee open platform through the following steps: Register a developer → create an application → obtain interface permissions.

2.1 GitHub login development process

  1. Register and log in to github

  2. Click Settings -> Developer settings under the avatar and click New OAuth App on the right side

  3. Fill in the relevant configuration of the application app, there are 2 key configuration items

  4. Homepage URL This is the URL that needs to be authorized later, you can understand it as the root directory address of your project

  5. Authorization callback URL The callback address after successful authorization, this is very important, this is the callback address given to you when you get the authorization code.

2.2 Register GitHub account

  Register/login account on GitHub official website as required (official website address: https://github.com ), and complete the login

3. Application access application

    Before the application is connected, an application must be made first to obtain the corresponding appid and appkey, so as to ensure that the website and users can be correctly authenticated and authorized in the subsequent process.

3.1 Create an application

1. After successful login, click the "Avatar" button in the upper right corner, and click the "Settings" button

2. Jump to the settings page and select the "Developer settings" button

3. Jump to the "Developer settings" page, select the "OAuth Apps" button, and click Create Application, mine has been approved and an application has been created.

4. Fill in the application-related information, where: the callback address is the address where GitHub calls back to the application and returns the authorization code after the user authorizes.

5. Fill in the website information, click "Create Application", the website application is created, and the Client ID  and  Client Secrets will be generated . They will be used in the basic flow of OAuth2 authentication above.

Application for clientID and clientSecret

  clientID: the unique identifier of the application.

  clientSecret: The key corresponding to clientID, used to verify the legitimacy of the application when accessing user resources.

  Application Address: Sign in to GitHub · GitHub

Note : Keep the clientID and clientSecrets information confidential and do not disclose them at will.

3.2 At this point, the preparatory work is over, and the website development process (introduced in the next part)

3.3 Everyone's project needs are different, and different problems may arise. This article is for reference only

3.4 SpringBoot+Vue implements third-party GitHub login (2)

3.5 Other third-party login methods: https://www.cnblogs.com/liyhbk/category/2089783.html

4. Source code purchase

4.1 Concise version ( Taobao source code )

Including login, third-party login, jump homepage, SpringBoot+SpringSecurity+Mysql+Redis+Vue+ElementUI, etc.

4.2 Multifunctional version ( Taobao source code )

Including login, registration, third-party login, complete system management module, system tool module, system monitoring module, personal center, etc., SpringBoot+SpringSecurity+Mysql+Redis+Vue+ElementUI, etc.

Guess you like

Origin blog.csdn.net/liyh722/article/details/131590177