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

1. Weibo login introduction (test website: address )

Weibo login includes identity authentication, user relationship and content dissemination. Users are allowed to use Weibo accounts to log in to access third-party websites, share content, and synchronize information. It has the following characteristics:

  1. Log in to your app or website directly with your Weibo account.

  2. Obtain high-quality active Weibo users.

  3. It is more convenient to share to Weibo and improve the power of information dissemination on the website.

1.1 Authorization mechanism

  Calling the Weibo open interface, such as posting Weibo, obtaining basic user information, obtaining popular Weibo content, etc., all require user identity authentication. Currently, OAuth2.0 is mainly used for user identity authentication on the Weibo open platform. In addition, for the convenience of developers to open

To develop and test your own application, we also provide the identity authentication method authorized by the developer itself, but the authorization by the developer itself is only applicable to the developer's own calling interface to which the application belongs.

interface documentation

  Developers can first browse the OAuth2.0 interface document to get familiar with the meaning of the OAuth2.0 interface and parameters, and then we explain how to use OAuth2.0 according to the application scenarios.

interface illustrate
OAuth2/authorize Request user authorization Token
OAuth2/access_token Obtain authorized Access Token
OAuth2/get_token_info Authorization information query interface
OAuth2/revokeoauth2 Authorized recycling interface
OAuth2/get_oauth2_token Replace the Access Token of OAuth1.0 to the Access Token of OAuth2.0


Precautions

  1. No application is required for OAuth2.0 authorization, and any application can use it. If the developer needs a longer authorization validity period, please refer to the authorization validity period section of this document.

  2. If you are an off-site web application or client application, for security reasons, you need to fill in the redirect_url (authorization callback page) on the platform website to use OAuth2.0, fill in the address: "My App > Application Information > Advanced information", for clients,

The default callback page address is provided. For details, please refer to the function section of the authorization page.

2. Become a developer (official website address: Sina Weibo Open Platform-Homepage )

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

2.1 Registered Developer

  On the homepage of the Weibo open platform (official website address:  Sina Weibo open platform-homepage ), register as a developer.

2.2 After successful login, you will go to the developer registration page, and submit the basic information of the company or individual as required on the registration page. The figure below shows the individual developer registration page:

2.3 After submitting the materials as required, the reviewers will conduct a review. After passing the review, identity verification is required, upload the ID card information, and wait for review after submission.

3. Website application and mobile 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 the developer registration is complete, click the "My App" button.

2. Jump to the Weibo application center page, click Create Application, mine has been approved and an application has been created.

3. Choose to create an application, and select the type of application to be created. Let’s take a website application as an example. After clicking Create a website application, complete the information as required:

4. After filling in the website information, you can view the App Key and App Secret obtained from the website.

3.2 Perfect website information

1. Click "My App", "Application Information" on the right side of the application, and edit the authorization callback page in the advanced information, which must be consistent with the callback address in the following code:

3.3 Official code SDK download ( SDK sample code download

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

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

3.6 SpringBoot+Vue implements third-party Weibo login (2)

3.7 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/129421165