Method and device for parallelizing online operation and test debugging of authorization process
By configuring the online address in the authorization process of the social media platform and adding the test_url field in the localStorage, the problem of complex callback address configuration and poor user experience in the authorization process is solved, and the parallelization of online operation and test debugging is achieved, and development efficiency and security are improved.
Patent Information
- Application Number
- CN202411788652.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-12-06
AI Technical Summary
The prior art has problems such as complex callback address configuration, poor user experience, and inconvenient development and debugging in the authorization process of social media platform homepage.
By configuring an online address U in the callback address configuration item provided by the social media platform, and adding the test_url field through localStorage in the test environment, using the judgment function Fp to determine whether the test_url field exists in the localStorage. If it exists, it will be redirected to the test environment for a secondary callback, so as to realize parallelism between online operation and test debugging.
It realizes the effects of flexible switching of environments, reducing development costs, maintaining the stability of the online environment, rapid iteration and debugging, easy management and maintenance, and enhanced security.
Smart Images

Figure CN119621594A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method, device and electronic equipment for parallel online operation and testing and debugging of an authorization process. Background Art
[0002] The authorization process of the social media platform homepage refers to the process in which users authorize applications to access their social media accounts so that the applications can perform specific actions on behalf of users, such as obtaining user information, publishing content, etc. The user clicks the "Login" or "Connect to Social Media" button in the application to trigger the authorization request. The application redirects the user to the authorization page of the social media platform, which displays a dialog box asking the user to authorize the application to access certain permissions of their account, usually containing parameters such as client_id (unique identifier of the application), redirect_uri (URL callback after successful authorization), response_type (response type, usually code), scope (scope of requested permissions, such as email, public_profile, etc.) and state (a random string used to prevent CSRF attacks).
[0003] The existing technology has the following defects in the development process of the authorization process of the social media platform homepage:
[0004] 1. In the authorization process of the social media platform homepage, a callback address needs to be specified in the background of the platform. Some social media platforms provide multiple apps for binding different callback addresses, but multiple apps need to be maintained at the same time. Some platforms only provide one app and can only bind one callback address. Once the business is online, it will be inconvenient to debug in the development environment if you want to adjust it again.
[0005] 2. The authorization page design of some social media platforms is complex, and users may be confused and do not know the specific meaning of authorization, which affects the user experience. If the application frequently requests user authorization, users may feel annoyed and even cancel the authorization. When the user refuses authorization or the authorization fails, the application needs to have a friendly error prompt and recovery mechanism, otherwise it may cause user loss.
[0006] The above problems become technical problems that need to be solved. Summary of the invention
[0007] In view of this, an embodiment of the present invention provides a method, device and electronic device for parallel online operation and testing and debugging of an authorization process, which at least partially solves the problems existing in the prior art.
[0008] In a first aspect, an embodiment of the present invention provides a method for parallel online operation and testing and debugging of an authorization process, comprising:
[0009] Configure an online address U in the callback address configuration item provided by the social media platform. The online address U is used to receive the callback data from the social media platform and process the authorization operation.
[0010] When developing and debugging in the test environment, add a field named test_url to the localStorage of the browser of the online project. The value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment.
[0011] Add a judgment function Fp to the callback address corresponding to the online project. The judgment function Fp is used to check whether there is a field named test_url in the browser localStorage. If the test_url field exists, stop executing the normal online authorization operation process, intercept the search parameter P carried by the callback return of the social media platform, and splice the search parameter P to test_url to form a new callback link L=T+'?'+P. Use the window.open method to open the spliced test_url link L for a second callback;
[0012] In the page corresponding to test_url in the test environment, obtain the parameter P carried in the redirection address bar from the online environment, and pull the homepage based on the parameter P carried in the address bar;
[0013] After debugging in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project.
[0014] According to a specific implementation of an embodiment of the present invention, configuring an online address U in the callback address configuration item provided by the social media platform includes:
[0015] Write an API endpoint on the server, the API endpoint is used to receive callback data sent by the social media platform, verify the callback parameters, obtain the access token, and save the user information in the API endpoint.
[0016] According to a specific implementation of an embodiment of the present invention, configuring an online address U in the callback address configuration item provided by the social media platform also includes:
[0017] Enter the online address U in the configuration item of the developer console of the social media platform;
[0018] After the user completes the authorization through the social media platform, obtain the authorization code returned by the platform;
[0019] Use the received authorization code to call the social media platform's API in exchange for the user's access token.
[0020] According to a specific implementation of an embodiment of the present invention, when developing and debugging in a test environment, a field named test_url is added to the localStorage of the browser of the online project, including:
[0021] In the developer tools, find and switch to the Application tab;
[0022] Add a new key-value pair in the localStorage panel list corresponding to the Application tag. The key name is test_url and the value is the test environment address T.
[0023] According to a specific implementation of an embodiment of the present invention, the step of adding a judgment function Fp to the callback address corresponding to the online project includes:
[0024] Add JS code to the page corresponding to the callback address, and add the interrupt function Fp to the JS code.
[0025] According to a specific implementation of an embodiment of the present invention, the use of the window.open method to open the spliced test_url link L for secondary callback includes:
[0026] Using the window.open method to open the concatenated test_url link L will cause the browser to navigate to the new URL and redirect the user to the callback page of the test environment;
[0027] By setting the second parameter of the window.open method to _self, a new callback link L is opened in the current window.
[0028] According to a specific implementation of an embodiment of the present invention, the operation of obtaining the parameter P carried in the redirection back address bar from the online environment in the page corresponding to test_url in the test environment, and pulling the homepage based on the parameter P carried in the address bar includes:
[0029] The query string part is extracted from the URL in the address bar, the key-value pairs in the string are extracted based on the separator contained in the string, and the extracted key-value pairs are used as the parameter P carried in the address bar.
[0030] According to a specific implementation of an embodiment of the present invention, the operation of obtaining the parameter P carried in the redirection back address bar from the online environment in the page corresponding to test_url in the test environment, and pulling the homepage based on the parameter P carried in the address bar, further includes:
[0031] In the console, use the code parameter to obtain an access token, and use the access token to pull the home page content.
[0032] In a second aspect, an embodiment of the present invention provides a device for online operation and parallel testing and debugging of an authorization process, including:
[0033] The configuration module configures an online address U in the callback address configuration item provided by the social media platform, and the online address U is used to receive the callback data of the social media platform and process the authorization operation;
[0034] Add a module. When developing and debugging in the test environment, add a field named test_url to the localStorage of the browser of the online project. The value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment.
[0035] In the judgment module, a judgment function Fp is added to the callback address corresponding to the online project. The judgment function Fp is used to check whether there is a field named test_url in the browser localStorage. If the test_url field exists, the normal online authorization operation process is stopped, the search parameter P carried by the callback return of the social media platform is intercepted, and the search parameter P is concatenated with test_url to form a new callback link L=T+'?'+P. The window.open method is used to open the concatenated test_url link L for a second callback.
[0036] The targeting module obtains the parameter P carried in the redirection address bar from the online environment in the page corresponding to test_url in the test environment, and pulls the homepage based on the parameter P carried in the address bar;
[0037] Delete the module. After debugging in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project.
[0038] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:
[0039] at least one processor; and,
[0040] a memory communicatively connected to the at least one processor; wherein,
[0041] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of parallel operation of the authorization process online and testing and debugging in any of the aforementioned first aspects or any implementation of the first aspect.
[0042] In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the method of online running of the authorization process and parallel testing and debugging in the aforementioned first aspect or any implementation method of the first aspect.
[0043] In a fifth aspect, an embodiment of the present invention further provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the method of online running of the authorization process and parallel testing and debugging in the aforementioned first aspect or any implementation of the first aspect.
[0044] The scheme for running the authorization process online and testing and debugging in parallel in the embodiment of the present invention includes: configuring an online address U in the callback address configuration item provided by the social media platform, and the online address U is used to receive the callback data of the social media platform and process the authorization operation; when developing and debugging in the test environment, adding a field named test_url to the browser localStorage of the online project, and the value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment; adding a judgment function Fp to the callback address corresponding to the online project, and the judgment function Fp is used to check whether there is a field named test_url in the browser localStorage, and if it exists, test_url field, then stop executing the normal online authorization operation process, intercept the search parameter P carried by the callback return of the social media platform, splice the search parameter P to test_url to form a new callback link L=T+'?'+P, use the window.open method to open the spliced test_url link L for a second callback; in the page corresponding to test_url in the test environment, obtain the parameter P carried by the redirection back to the address bar from the online environment, and pull the homepage based on the parameter P carried by the address bar; after the debugging work in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project. This solution has the following beneficial effects:
[0045] 1. Flexible environment switching: By adding the test_url field in localStorage, you can easily switch the callback process from the online environment to the test environment without modifying the backend configuration, which improves the flexibility of development and debugging.
[0046] 2. Reduce development costs: There is no need to configure a callback address for the test environment separately, which reduces the workload of configuration and management and reduces development costs.
[0047] 3. Maintain a stable online environment: When debugging in a test environment, the normal authorization process of the online environment will not be affected, ensuring the normal use and experience of online users.
[0048] 4. Rapid iteration and debugging: Developers can quickly iterate and debug the authorization process in a test environment, which improves development efficiency and shortens the development cycle.
[0049] 5. Easy to manage and maintain: The callback process is controlled through simple localStorage operations, making environment switching and management simpler and more intuitive, and easy to maintain.
[0050] 6. Enhanced security: By controlling environment switching through localStorage, the confusion of sensitive information in different environments is avoided, thus enhancing the security of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0052] Figure 1 A flowchart of a method for parallel online operation and testing and debugging of an authorization process provided by an embodiment of the present invention;
[0053] Figure 2 A flowchart of another method for parallel online operation and testing and debugging of an authorization process provided by an embodiment of the present invention;
[0054] Figure 3 A schematic diagram of the structure of a device for online operation and parallel testing and debugging of an authorization process provided by an embodiment of the present invention;
[0055] Figure 4 A schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0057] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0058] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0059] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0060] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0061] The embodiment of the present disclosure provides a method for parallel operation of authorization process online and testing and debugging. The method for parallel operation of authorization process online and testing and debugging provided in this embodiment can be executed by a computing device, which can be implemented as software, or as a combination of software and hardware, and the computing device can be integrated in a server, terminal device, etc.
[0062] See also Figure 1 and Figure 2 The embodiment of the present disclosure provides a method for parallel online operation and testing and debugging of an authorization process, including:
[0063] S101, configure an online address U in the callback address configuration item provided by the social media platform, and the online address U is used to receive the callback data of the social media platform and process the authorization operation.
[0064] Configure an online address U in the callback address configuration item provided by the social media platform to receive callback data from the social media platform and process authorization operations, which usually involves the following steps:
[0065] Set up a publicly accessible server to deploy the application. This server needs to be able to receive HTTP requests from the social media platform. Write an API endpoint on the server (for example, / auth / callback), which will receive the callback data sent by the social media platform. You need to implement the logic for handling the authorization response in this endpoint, such as verifying the callback parameters, obtaining the access token, saving the user information, etc.
[0066] Go to the developer console of the social media platform you are using and find the application management section. In the application settings, find the relevant configuration items such as "Callback URL" or "Redirect URI". Here, enter the prepared online address U (for example, https: / / yourdomain.com / auth / callback).
[0067] When the user completes the authorization through the social media platform, the platform will redirect the user to the configured callback address U with some parameters, such as the authorization code, state, etc. On the server side, it is necessary to verify the validity of these parameters, especially the state parameter, to prevent CSRF attacks. Use the received authorization code to call the social media platform's API in exchange for the user's access token. With the access token, you can obtain the user's basic information and save it in the database for subsequent use.
[0068] Through the above steps, an online address U can be successfully configured in the callback address configuration item provided by the social media platform to receive the callback data of the social media platform and process the authorization operation.
[0069] S102, when developing and debugging in the test environment, add a field named test_url in the localStorage of the browser of the online project, the value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment.
[0070] You can use a browser that supports developer tools (such as Chrome, Firefox, Safari, etc.) to open the web page of the online project.
[0071] In the developer tools, find and switch to the "Application" or "Storage" tab. This tab usually contains storage information such as localStorage, sessionStorage, Cookies, etc. Under the "Application" or "Storage" tab, find the localStorage option. There is usually a drop-down list to select the domain name of the online project.
[0072] In the localStorage panel, you will see a list of key-value pairs. Click the "+" button or directly add a new key-value pair in the list. Fill in the key name (Key) with test_url, and fill in the test environment address T (Value), for example, http: / / test.yourdomain.com / callback.
[0073] Through the above steps, you can successfully add the test_url field to the browser localStorage without writing any code to instruct the callback process to redirect to the test environment.
[0074] S103, add a judgment function Fp to the callback address corresponding to the online project, and the judgment function Fp is used to check whether there is a field named test_url in the browser localStorage. If the test_url field exists, stop executing the normal online authorization operation process, intercept the search parameter P carried by the callback return of the social media platform, and splice the search parameter P to test_url to form a new callback link L=T+'?'+P. Use the window.open method to open the spliced test_url link L for a second callback.
[0075] Specifically, you can find and switch to the "Console" tab in the developer tools. This tab is used to run JavaScript code and view output information.
[0076] In the Console tab, you can write and run a JavaScript function to implement the required logic to achieve the following functions:
[0077] 1. Check if the test_url field exists in localStorage
[0078] You can use localStorage.getItem('test_url') to check if the test_url field exists.
[0079] 2. If the test_url field exists:
[0080] Stop the normal authorization process online and get the search parameter (query string) in the URL.
[0081] After concatenating the search parameter to test_url, a new callback link L is formed. Use the window.open method to open the new callback link L for secondary callback.
[0082] 3. If the test_url field does not exist: Continue to execute the normal online authorization operation process.
[0083] Through the above steps, you can add the judgment function Fp to the callback address corresponding to the online project without writing any code, and process the callback process according to the test_url field in localStorage.
[0084] S104, obtaining the parameter P carried in the address bar of the redirection back from the online environment from the page corresponding to test_url in the test environment, and performing an operation of pulling the homepage based on the parameter P carried in the address bar.
[0085] In the developer tools, you can switch to the "Network" tab, which is used to view network requests.
[0086] In the request details, check the query string of the URL (i.e., search parameters). These parameters are the parameters P carried in the address bar when redirecting back from the online environment. In the address bar of the browser, you can see the complete URL, including the query string. For example:
[0087] http: / / test.yourdomain.com / callback?code=abc123&state=xyz789
[0088] Manually extract the parameters in the query string, such as code=abc123 and state=xyz789.
[0089] In the "Console" tab of the developer tools, you can run JavaScript code to use the extracted parameters to pull the home page.
[0090] S105, after the debugging work in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project.
[0091] You can find the localStorage option under the "Application" or "Storage" tab. There is usually a drop-down list to select the domain name of the online project. In the localStorage panel, you will see a list of key-value pairs. Find the entry with the key name test_url. Right-click the test_url entry and select the "Delete" option. Alternatively, you can directly click on the value part of the test_url entry, delete its content, and then press Enter to save.
[0092] Through the above steps, you can manually delete the test_url field in the browser localStorage corresponding to the online project without writing any code.
[0093] According to a specific implementation of an embodiment of the present invention, configuring an online address U in the callback address configuration item provided by the social media platform includes:
[0094] Write an API endpoint on the server, the API endpoint is used to receive callback data sent by the social media platform, verify the callback parameters, obtain the access token, and save the user information in the API endpoint.
[0095] According to a specific implementation of an embodiment of the present invention, configuring an online address U in the callback address configuration item provided by the social media platform also includes:
[0096] Enter the online address U in the configuration item of the developer console of the social media platform;
[0097] After the user completes the authorization through the social media platform, obtain the authorization code returned by the platform;
[0098] Use the received authorization code to call the social media platform's API in exchange for the user's access token.
[0099] According to a specific implementation of an embodiment of the present invention, when developing and debugging in a test environment, a field named test_url is added to the localStorage of the browser of the online project, including:
[0100] In the developer tools, find and switch to the Application tab;
[0101] Add a new key-value pair in the localStorage panel list corresponding to the Application tag. The key name is test_url and the value is the test environment address T.
[0102] According to a specific implementation of an embodiment of the present invention, the step of adding a judgment function Fp to the callback address corresponding to the online project includes:
[0103] Add JS code to the page corresponding to the callback address, and add the interrupt function Fp to the JS code.
[0104] According to a specific implementation of an embodiment of the present invention, the use of the window.open method to open the spliced test_url link L for secondary callback includes:
[0105] Using the window.open method to open the concatenated test_url link L will cause the browser to navigate to the new URL and redirect the user to the callback page of the test environment;
[0106] By setting the second parameter of the window.open method to _self, a new callback link L is opened in the current window.
[0107] According to a specific implementation of an embodiment of the present invention, the operation of obtaining the parameter P carried in the redirection back address bar from the online environment in the page corresponding to test_url in the test environment, and pulling the homepage based on the parameter P carried in the address bar includes:
[0108] The query string part is extracted from the URL in the address bar, the key-value pairs in the string are extracted based on the separator contained in the string, and the extracted key-value pairs are used as the parameter P carried in the address bar.
[0109] According to a specific implementation of an embodiment of the present invention, the operation of obtaining the parameter P carried in the redirection back address bar from the online environment in the page corresponding to test_url in the test environment, and pulling the homepage based on the parameter P carried in the address bar, further includes:
[0110] In the console, use the code parameter to obtain an access token, and use the access token to pull the home page content.
[0111] Corresponding to the above method embodiment, see Figure 3 The embodiment of the present invention also discloses a device 30 for parallel operation of authorization process online and testing and debugging, including:
[0112] Configuration module 301, configuring an online address U in the callback address configuration item provided by the social media platform, the online address U is used to receive the callback data of the social media platform and process the authorization operation;
[0113] Adding module 302, when developing and debugging in the test environment, adds a field named test_url to the localStorage of the browser of the online project, the value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment;
[0114] The judgment module 303 adds a judgment function Fp to the callback address corresponding to the online project. The judgment function Fp is used to check whether there is a field named test_url in the browser localStorage. If the test_url field exists, the normal online authorization operation process is stopped, the search parameter P carried by the callback return of the social media platform is intercepted, and the search parameter P is concatenated with the test_url to form a new callback link L=T+'?'+P. The window.open method is used to open the concatenated test_url link L for a second callback;
[0115] The orientation module 304 obtains the parameter P carried in the redirection address bar from the online environment in the page corresponding to test_url in the test environment, and performs an operation of pulling the homepage based on the parameter P carried in the address bar;
[0116] Deletion module 305, after the debugging work in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project.
[0117] See also Figure 4 The embodiment of the present invention further provides an electronic device 60, the electronic device comprising:
[0118] at least one processor; and,
[0119] a memory communicatively connected to the at least one processor; wherein,
[0120] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method of authorizing the online running of the process and testing and debugging in parallel in the aforementioned method embodiment.
[0121] An embodiment of the present invention further provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the aforementioned method embodiment.
[0122] An embodiment of the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the method of online running of the authorization process and parallel testing and debugging in the aforementioned method embodiment.
[0123] Reference below Figure 4 , which shows a schematic diagram of the structure of an electronic device 60 suitable for implementing the embodiment of the present disclosure. The electronic device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0124] like Figure 4 As shown, the electronic device 60 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 60 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0125] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, a gage, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 60 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 60 is shown with various devices, but it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have instead.
[0126] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0127] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for parallel online operation and testing and debugging of an authorization process, characterized in that: include: Configure an online address U in the callback address configuration item provided by the social media platform. The online address U is used to receive the callback data from the social media platform and process the authorization operation. When developing and debugging in the test environment, add a field named test_url to the localStorage of the browser of the online project. The value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment. Add a judgment function Fp to the callback address corresponding to the online project. The judgment function Fp is used to check whether there is a field named test_url in the browser localStorage. If the test_url field exists, stop executing the normal online authorization operation process, intercept the search parameter P carried by the callback return of the social media platform, and splice the search parameter P to test_url to form a new callback link L=T+'?'+P. Use the window.open method to open the spliced test_url link L for a second callback; In the page corresponding to test_url in the test environment, obtain the parameter P carried in the redirection address bar from the online environment, and pull the homepage based on the parameter P carried in the address bar; After debugging in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project.
2. The method according to claim 1, characterized in that The step of configuring an online address U in the callback address configuration item provided by the social media platform includes: Write an API endpoint on the server, the API endpoint is used to receive callback data sent by the social media platform, verify the callback parameters, obtain the access token, and save the user information in the API endpoint.
3. The method according to claim 2, characterized in that The step of configuring an online address U in the callback address configuration item provided by the social media platform further includes: Enter the online address U in the configuration item of the developer console of the social media platform; After the user completes the authorization through the social media platform, obtain the authorization code returned by the platform; Use the received authorization code to call the social media platform's API in exchange for the user's access token.
4. The method according to claim 3, characterized in that When developing and debugging in the test environment, add a field named test_url to the localStorage of the browser of the online project, including: In the developer tools, find and switch to the Application tab; Add a new key-value pair in the localStorage panel list corresponding to the Application tag. The key name is test_url and the value is the test environment address T.
5. The method according to claim 4, characterized in that The judgment function Fp is added to the callback address corresponding to the online project, including: Add JS code to the page corresponding to the callback address, and add the interrupt function Fp to the JS code.
6. The method according to claim 5, characterized in that The window.open method is used to open the concatenated test_url link L for secondary callback, including: Using the window.open method to open the concatenated test_url link L will cause the browser to navigate to the new URL and redirect the user to the callback page of the test environment; By setting the second parameter of the window.open method to _self, a new callback link L is opened in the current window.
7. The method according to claim 6, characterized in that The operation of obtaining the parameter P carried in the redirection address bar from the online environment in the page corresponding to test_url in the test environment, and pulling the homepage based on the parameter P carried in the address bar, includes: The query string part is extracted from the URL in the address bar, the key-value pairs in the string are extracted based on the separator contained in the string, and the extracted key-value pairs are used as the parameter P carried in the address bar.
8. The method according to claim 7, characterized in that The operation of obtaining the parameter P carried in the redirection address bar from the online environment in the page corresponding to test_url in the test environment, and pulling the homepage based on the parameter P carried in the address bar, further includes: In the console, use the code parameter to obtain an access token, and use the access token to pull the home page content.
9. A device for parallel online operation and testing and debugging of authorization processes, characterized in that: include: The configuration module configures an online address U in the callback address configuration item provided by the social media platform, and the online address U is used to receive the callback data of the social media platform and process the authorization operation; Add a module. When developing and debugging in the test environment, add a field named test_url to the localStorage of the browser of the online project. The value of the test_url field is the address T of the test environment, which is used to indicate that the callback process is redirected to the test environment. In the judgment module, a judgment function Fp is added to the callback address corresponding to the online project. The judgment function Fp is used to check whether there is a field named test_url in the browser localStorage. If the test_url field exists, the normal online authorization operation process is stopped, the search parameter P carried by the callback return of the social media platform is intercepted, and the search parameter P is concatenated with test_url to form a new callback link L=T+'?'+P. The window.open method is used to open the concatenated test_url link L for a second callback; The targeting module obtains the parameter P carried in the redirection address bar from the online environment in the page corresponding to test_url in the test environment, and pulls the homepage based on the parameter P carried in the address bar; Delete the module. After debugging in the test environment is completed, manually delete the test_url field in the browser localStorage corresponding to the online project.
10. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method for online running of an authorization process and parallel testing and debugging as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Payment platform authorization redirection method and system in cross-browser environment
CN114331409A
Page processing method and device
CN117193907A
User access method and device based on unified identity authentication
CN117473531A
Method and device for realizing universal mainstream media authorization homepage
CN118041995A
Communication device for providing function of internetaccess by using link information stored in localstorage means and method for operating of the device
KR1020070037779A