我正在使用 Laravel 6.7 并尝试使用Passport进行用户身份验证。
我可以在用户注册时为他们创建访问令牌。这是代码:
$user = User::create($input);
$user->createToken('auth-token');
Run Code Online (Sandbox Code Playgroud)
正如我在AuthServiceProvider.php文件boot()函数中定义的那样,此访问令牌的有效期为 15 分钟,如下所示:
Passport::personalAccessTokensExpireIn(Carbon::now()->addMinutes(15));
Run Code Online (Sandbox Code Playgroud)
我想使用刷新令牌刷新它,但似乎无法理解如何。
我到处找(包括 Laravel 网站),他们都告诉我这样做:
$http = new GuzzleHttp\Client;
$response = $http->post('http://your-app.com/oauth/token', [
'form_params' => [
'grant_type' => 'refresh_token',
'refresh_token' => 'the-refresh-token',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'scope' => '',
],
]);
Run Code Online (Sandbox Code Playgroud)
没有任何明确的解释,以什么价值观'the-refresh-token','client-id'并'client-secret'意味着是。
堆栈溢出的一个答案如下:
您必须发送旧的刷新令牌 (
'refresh_token' => 'the-refresh-token') 并且此代码生成一个新令牌和刷新刷新。
但是我没有刷新令牌,我正在尝试创建一个。我只是创建一个随机字符串吗?
所以我正在研究Redox OS(一个用 Rust 制作的操作系统)的源代码,看看我是否能学到一些东西。
我读的汇编文件的start.s中bootloader的文件夹。在interrupt_vector_table标签中,我们有:
interrupt_vector_table:
b . @ Reset
b .
b . @ SWI instruction
b .
b .
b .
b .
b .
Run Code Online (Sandbox Code Playgroud)
究竟是b .什么?
我不是一个完整的组装初学者,我以前从未遇到过这种情况。
我目前正在 YouTube上查看x64汇编教程。
我现在所做的只是一些基本的事情,例如使用C++函数ASSEMBLY和使用mov指令将值移入寄存器。
这是C++代码:
#include <iostream>
using namespace std;
extern "C" void SomeFunction();
int main() {
SomeFunction();
// Just putting this here to stop the program from closing immediately after opening
cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是ASSEMBLY代码:
.code
SomeFunction proc
mov ax, -1
ret
SomeFunction endp
end
Run Code Online (Sandbox Code Playgroud)
问题:每当我运行Local Window Debugger并尝试将Watch添加到寄存器时ax,我都在使用Visual Studio Community 2017 ,但我一直收到错误消息'Error reading register value'。
我要去哪里错了?
抱歉,如果不清楚,请让我知道,我可以尝试更好地解释。
更新:因此,我尝试使用rbx …
所以我正在阅读Linux From Scratch一书,并在章节5.17 Bison-3.0.4中.
这本书指示我们做一个make check后来make测试编译的Bison包的结果.
最初,我收到以下错误:
make[3]: Entering directory `/sources/bison-3.0'
LEX examples/calc++/calc++-scanner.cc
CXX
examples/calc++/examples_calc___calc__-calc++-scanner.o
g++: error: ./examples/calc++/calc++-scanner.cc: No such file or directory
g++: fatal error: no input files
compilation terminated.
make[3]: ***
[examples/calc++/examples_calc___calc__-calc++-scanner.o] Error 1
make[3]: Leaving directory `/sources/bison-3.0'
make[2]: *** [check-am] Error 2
make[2]: Leaving directory `/sources/bison-3.0'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/sources/bison-3.0'
make: *** [check] Error 2
Run Code Online (Sandbox Code Playgroud)
但是在这个网站上得到了解决方案.在发出之前告诉我要做以下事情make check:
cp Makefile Makefile.bak …Run Code Online (Sandbox Code Playgroud) 我不知道这是否离题,但在 Laravel 中,我们可以在.env文件中设置变量,然后我们可以使用getenv()函数访问该文件以防止对其进行硬编码,这可能不安全。
我们可以在 Android Studio(使用 Java)中做同样的事情吗?由于有一些信息,我宁愿不进行硬编码。
希望这是有道理的。
我尝试在类中设置变量并通过类访问它们,但我觉得有一种更好的方法,更类似于在 Laravel 中的做法。
这是我现在正在做的事情,但这不是我要找的:
public class EnvVariables {
public final String API_KEY = "some API key";
public final String API_ENDPOINT = "https://example.com/api/v1/endpoint";
}
Run Code Online (Sandbox Code Playgroud)
然后我在需要的地方使用这些变量。
这可以完成工作,但是该类仍然可以轻松访问,而 a.env则不是(因为它不应该)。
我正在按照本教程学习如何在Rust中创建一个非常基本的操作系统.这是我目前的状态:
Cargo.toml
[package]
name = "blog_os"
version = "0.1.0"
authors = ["Philipp Oppermann <dev@phil-opp.com>"] # Here I used my own details
[lib]
crate-type = ["staticlib"]
Run Code Online (Sandbox Code Playgroud)
SRC/lib.rs
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub extern fn rust_main() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] #[no_mangle] pub extern fn panic_fmt() -> ! {loop{}}
Run Code Online (Sandbox Code Playgroud)
x86_64的-blog_os.json
{
"llvm-target": "x86_64-unknown-none",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"linker-flavor": "gcc",
"target-endian": "little",
"target-pointer-width": "64",
"target-c-int-width": "32",
"arch": "x86_64",
"os": "none",
"disable-redzone": true,
"features": "-mmx,-sse,+soft-float"
}
Run Code Online (Sandbox Code Playgroud)
这是Makefile. …
所以我正在阅读一些用于学习目的的汇编源代码,并且遇到了一些非常奇怪的东西(或者我可能只是一个新东西):
.ver:
mov al, [redoxfs.header + Header.version + bx]
mov ah, [.version + bx]
cmp al, ah
jne .ver_err
inc bx
jl .ver
Run Code Online (Sandbox Code Playgroud)
所以在这个子标签中我们有两个跳转指令.
但是,关于最后一次跳转指令jl.如果我错了,请纠正我,但是cmp因为它是有条件的,所以不应该在跳之前有一个吗?
我最初认为它是基于cmp al, ah,但jne如果不相等则跳跃.
我错过了什么吗?
我尝试使用 Firebase Cloud Messaging 从我的服务器发送推送通知,但不断收到以下错误:
客户端错误:
POST https://fcm.googleapis.com/v1/projects/my-project/messages:send导致401 Unauthorized响应...请求的身份验证凭据无效。预期的 OAuth 2 访问
我在网上到处查看,到处都提到“使用服务器密钥而不是 API 密钥”。我正在这样做,但仍然收到错误。网上没有任何帮助。
这是我的要求:
POST https://fcm.googleapis.com/v1/projects/my-project/messages:send
Headers:
Authorization: Bearer <MY SERVER KEY>
Content-Type: application/x-www-form-urlencoded (I have also tried application/json)
Body:
{
"message": {
"topic": "",
"notifications": {
"title": "Some title",
"body": "Some notification body"
}
}
}
Run Code Online (Sandbox Code Playgroud)
直接从 Firebase 控制台推送通知工作得很好,我只是无法让它在服务器端工作。
我正在关注此汇编源代码以进行学习,并遇到以下几行:
# load a disk extent into high memory
# eax - sector address
# ecx - sector count
# edi - destination
load_extent:
; loading kernel to 1MiB
; move part of kernel to startup_end via bootsector#load and then copy it up
; repeat until all of the kernel is loaded
buffer_size_sectors equ 127
Run Code Online (Sandbox Code Playgroud)
有些行开头#似乎是注释。
然后他跟进标签load_extent:并添加以;.开头的评论。这是我习惯看到的。
这是故意这样做的,所以人们不会不小心复制他的代码?或者我错过了什么?
假设我有两条路线/firstRoute和/secondRoute,分别用于小部件FirstRoute和SecondRoute。我正在将一个命名路由与一些参数一起推送到堆栈上,就像这样......
Navigator.pushNamed(
context,
"/secondRoute",
arguments: <String, String>{"key" : "value"},
)
Run Code Online (Sandbox Code Playgroud)
我现在如何在SecondRoute中使用这个值?查看了文档,但没有提及。
所以我一直在阅读一些用于学习目的的汇编代码,并且遇到了这两个指令:
add register, value
add register, 'value' ; Where the value is now in single quotes
Run Code Online (Sandbox Code Playgroud)
这两者有什么区别?
在我被发现之前,如果这恰好是重复的话.我在这里问过,因为我不确切知道Google应该回答这个问题.