1. What is the OAuth protocol
OAuth (open authorization) is an open standard.
Allow third-party websites to access various information stored by users with service providers under the premise of user authorization.
This authorization does not require the user to provide the user name and password to the third-party website.
OAuth allows users to provide a token to a third-party website. A token corresponds to a specific third-party website, and the token can only access specific resources within a specific time.
2. The principle and authorization process of OAuth
The three parties involved in the authentication and authorization process of OAuth include:
Service provider: User use The service provider is generally used to store messages, photos, videos, contacts, files, etc. (such as Twitter, Sina Microwave, etc.).
User: User of the service provider
Third party: Usually a website that wants to access the user's information stored with the service provider.
For example, a website that provides photo printing services, where users want to print their online photo albums stored with the service provider.
Before the authentication process, the third party needs to apply to the service provider for the unique identifier of the third-party service.
The OAuth authentication and authorization process is as follows:
1. The user visits a third-party website and wants to operate certain resources stored by the user in the service provider.
2. The third-party website requests a temporary token from the service provider.
3. After the service provider verifies the identity of the third-party website, it grants a temporary token.
4. After the third-party website obtains the temporary token, it will direct the user to the service provider's authorization page to request user authorization. In the process, the temporary token and the return address of the third-party website will be sent to the service provider.
5. The user enters his or her username and password on the service provider's authorization page to authorize the third-party website to access the corresponding resources.
6. After the authorization is successful, the service provider will direct the user to the return address of the third-party website.
7. The third-party website obtains the access token from the service provider based on the temporary token.
8. The service provider grants third-party website access tokens based on the token and user authorization.
9. The third-party website uses the obtained access token to access the corresponding user resources stored in the service provider.
3. What are the websites that currently support OAuth?
t.sina.com.cn
t.qq.com
t.sohu.com
t.163.com
www.douban.com
www.twitter.com
www.facebook.com
Google Buzz
springboot encapsulates oauth2 protocol. There are two commonly used interfaces in it.
1. Get token
Interface: /oauth/token?
Parameters: ( grant_type is hard-coded, the other two are customized)
grant_type=password
username=development@cybergate-tech .com
password=oQd-BfT-cer-7LP
Full sample:http://localhost:9000 /oauth/token?grant_type=password&username=development@cybergate-tech.com&password=oQd-BfT-cer-7LP
Return result example:
{ "access_token": "beeaa54e-8391-4de0-8ba6-ce145b3fb812", "token_type": "bearer", "refresh_token": "8129769a-d804-46c7-856a-3bacd409b650", "expires_in": 3599, "scope": "read write" }
2. Refresh token
Interface:http://localhost:9000/oauth/token?
Parameters: (refresh_token is determined based on 1. Other parameters are hard-coded )
client_id=dashboard
client_secret=secret
- ##grant_type=refresh_token
- refresh_token=43dca105-627e-4f50-86e8-0c22c2f3abe9
http://localhost:9000/oauth/ token?client_id=dashboard&client_secret=secret&grant_type=refresh_token&refresh_token=43dca105-627e-4f50-86e8-0c22c2f3abe9
{ "access_token": "0135c92b-12ab-4af9-88f4-97ef85115e71", "token_type": "bearer", "refresh_token": "75d209b5-a30d-43a8-abcd-850e7fb62e76", "expires_in": 3599, "scope": "read write" }
The above is the detailed content of oAuth authentication and authorization. For more information, please follow other related articles on the PHP Chinese website!

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
