ABP with Swagger UI Test API report 401 No access problem

Source: Internet
Author: User
Tags response code

Problem Description:

When we test the Web API with the Swagger UI times 401 Error

Let's open the Get/api/services/app/role/getall, enter the parameters.

Click the Try it out! button to report 401 errors

Causes and Solutions

See an icon with a red exclamation mark in the upper-right corner

Click to view the reason is that the Access API needs to enter the authorization token value for verification, token value is the background based on the user dynamically generated, how to get it?

Solution, we can directly log in to the client to view the token value of the Access API

After I login successfully with admin, F12 Check the background token value of the browser and click on the link of request data to background request API under Network (NOTE: I use Google Chrome)

We found the authorization token information in the headers request headers inside the authorization.

Bearer Eyjhbgcioijiuzi1niisinr5cci6ikpxvcj9.eyjodhrwoi8vc2nozw1hcy54bwxzb2fwlm9yzy93cy8ymda1lza1l2lkzw50axr5l2nsywltcy9uyw1lawrl Bnrpzmllcii6ijiilcjodhrwoi8vc2nozw1hcy54bwxzb2fwlm9yzy93cy8ymda1lza1l2lkzw50axr5l2nsywltcy9uyw1lijoiywrtaw4ilcjbc3bozxqus Wrlbnrpdhkuu2vjdxjpdhltdgftcci6ijy3ndhlndq2lti4ywutywrjni0znmu2ltm5ztizmgfhnza3msisimh0dha6ly9zy2hlbwfzlm1py3jvc29mdc5jb2 0vd3mvmjawoc8wni9pzgvudgl0es9jbgfpbxmvcm9szsi6ikfkbwluiiwiahr0cdovl3d3dy5hc3buzxrib2lszxjwbgf0zs5jb20vawrlbnrpdhkvy2xhaw1 zl3rlbmfudelkijoimsisinn1yii6ijiilcjqdgkioii0n2u0y2ywnc05odyyltq4mjitotbhoc01njk1nwuwywe1m2uilcjpyxqioje1mte0ndu3mjusim5i Zii6mtuxmtq0ntcynswizxhwijoxntexntmymti1lcjpc3mioijzywfziiwiyxvkijoic2fhcyj9.exdes4lnkv4dkcfy-gtsf6kgdtk3a0bls3i6o7c2huq

Copy this authorization information to our backstage to authorize

Point development is now authorized to succeed

Then we test again, Response code has returned 200, and the test passed. Debug in the background break point

ABP with Swagger UI Test API report 401 No access problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.