草庐IT

auth_request

全部标签

javascript - 从 javascript 获取 HTTP Basic Auth 用户名?

我有一个只能通过http基本身份验证访问的网页。我怎样才能找出该页面中javascript中的基本身份验证用户名。即当有人访问它时(登录后),我想制作一个弹出窗口,上面写着“你好,你目前以用户$USERNAME身份登录” 最佳答案 这不可能完全来自JavaScript。您必须让服务器端脚本从请求中获取用户名,并将其插入生成的页面代码中,以便脚本获取。(例如varusername=(在此处插入JSON编码的字符串);。 关于javascript-从javascript获取HTTPBasic

javascript - 如何在jQuery中通过Request Body提交JSON数据?

我不是jQuery专家,认为我更新鲜。这是我的代码,不负责请求主体提交jQueryJSON数据。jQueryDatasubmittedbyJSONBodyRequest$.ajax({url:"/",type:"POST",data:[{id:1,name:"Shahed"},{id:2,name:"Hossain"}],contentType:"application/json;charset=utf-8",dataType:"json",success:function(){console.log("PurejQueryPureJSobject");}});Exampleofsub

javascript - 非常简单的 AngularJS $http POST 结果为 '400 (Bad Request)' 和 'Invalid HTTP status code 400'

我有一个非常简单的.NETWebAPI托管在Azure中,有两个非常简单的方法:[EnableCors(origins:"http://simpleapiearl.azurewebsites.net",headers:"*",methods:"*")]publicclassEnvelopesController:ApiController{//GET:api/EnvelopespublicIEnumerableGet(){returnnewstring[]{"value1","value2"};}//POST:api/EnvelopespublicstringPost([FromBod

javascript - Google api auth2 signOut 不工作

首先,我正在遵循本指南https://developers.google.com/identity/sign-in/web/和这个引用https://developers.google.com/identity/sign-in/web/reference.但我没有在window中声明回调,而是使用gapi.signin2.render函数来呈现按钮并在我的AngularController中为它附加一个处理程序。登录工作正常,问题是,当我尝试通过调用gapi.auth2.getAuthInstance().signOut()注销时,它只是不这样做。我注意到accounts.google

javascript - 如何复制具有不同 URL 的 Request 对象?

我正在围绕fetch编写一个包装器,我想在发出请求之前向URL添加一些内容,例如识别查询参数。我不知道如何使用与原始URL不同的URL制作给定Request对象的副本。我的代码如下所示://MyfunctionwhichtriestomodifytheURLoftherequestfunctionaddLangParameter(request){constnewUrl=request.url+"?lang="+lang;returnnewRequest(newUrl,/*notsurewhattoputhere*/);}//MyfetchwrapperfunctionmyFetch(

javascript - 仅从 firebase 导入 auth 和 firestore

我正在尝试减少我的vuejs应用程序中的firebase库大小。我目前将firebase导入为import*asfirebasefrom'firebase';require("firebase/firestore");在我的vendor文件中,我有数据库和消息服务,但我没有用到它们。如何只将auth和firestore导入到firebase对象中? 最佳答案 首先你需要导入核心import*asfirebasefrom'firebase/app';然后导入需要的模块import'firebase/auth';import'fireb

javascript - 如何对所有路由 Root 和 Child Routes 使用 angular 6 Route Auth Guards?

如何为所有路由Root和ChildRoutes使用angular6RouteAuthGuards? 最佳答案 1)[创建守卫,文件名类似于auth.guard.ts]nggenerateguardauthimport{Injectable}from'@angular/core';import{CanActivate,ActivatedRouteSnapshot,RouterStateSnapshot}from'@angular/router';import{Observable}from'rxjs/Observable';impor

javascript - 有什么方法可以同步执行 gapi.client.request 吗?

jQuery允许同步发送http请求(async:false设置),这在bypassingpopupblocker时特别有用。.在使用Google的javascript客户端库时有没有办法做到这一点Gapi? 最佳答案 没有。正如我所见,gapi.client.request中没有这样的选项。文档。 关于javascript-有什么方法可以同步执行gapi.client.request吗?,我们在StackOverflow上找到一个类似的问题: https:/

javascript - Vue 和 Axios CORS 错误 No 'Access-Control-Allow-Origin' header is present on the requested resource

这个问题在这里已经有了答案:XMLHttpRequestcannotloadXXXNo'Access-Control-Allow-Origin'header(11个答案)关闭4年前。我目前遇到上述错误,我正在使用Axios向外部API发出GET请求。看完Mozilla文档,做了很多研究并尝试了不同的选择,我仍然没有任何改善。我已经将代码剥离回到基础:axios.get('URL.com',{headers:{Access-Control-Allow-Origin:*},auth:{username:'username',password:'password'},}).then(func

javascript - AJAX 请求获取 "No ' Access-Control-Allow-Origin' header is present on the requested resource"错误

我尝试发送GET在jQueryAJAX请求中请求。$.ajax({type:'GET',url:/**/,dataType:'text/html',success:function(){alert("Success");},error:function(){alert("Error");},});但是,无论我尝试过什么,我都得到了XMLHttpRequestcannotload.No'Access-Control-Allow-Origin'headerispresentontherequestedresource.Origin'http://localhost:7776'isthere