标签: token

antlr4 python 3 从 plsql 语法打印或转储标记

我在Python中使用antlr4来读取以下语法:

https://github.com/antlr/grammars-v4/tree/master/plsql

文件 grants.sql 只有“begin select 'bob' from Dual; end;”

打印像树一样的 Lisp 的简单代码

from antlr4 import *
from PlSqlLexer import PlSqlLexer
from PlSqlParser import PlSqlParser
from PlSqlParserListener import PlSqlParserListener

input = FileStream('grants.sql')
lexer = PlSqlLexer(input)

stream = CommonTokenStream(lexer)
parser = PlSqlParser(stream)
tree = parser.sql_script()

print ("Tree " + tree.toStringTree(recog=parser));
Run Code Online (Sandbox Code Playgroud)

输出是这样的:

Tree (sql_script (unit_statement (anonymous_block BEGIN) (seq_of_statements (语句) (sql_statement (data_manipulation_language_statements (select_statement)) (子查询 (subquery_basic_elements (query_block SELECT (selected_element (select_list_elements (selected_element (select_list_elements (atom)常量 (quoted_string 'bob')))))))))))))) (from_clause FROM (table_ref_list (table_ref (table_ref_aux (table_ref_aux_internal (dml_table_expression_clause (tableview_name (identifier …

python tree parsing token antlr4

2
推荐指数
1
解决办法
2246
查看次数

使用 IHttpClientFactory 使用外部 API 时存储访问和刷新令牌的位置。网络核心

我使用 IHttpClientFactory 发送请求并接收从我的 Web API 到使用 Net Core 2.2 的外部 API 的 HTTP 响应。

用于向 API 发送请求的访问令牌和刷新令牌已存储在 appsettings.json 中。当请求返回 403 或 401 错误时,我会动态获取一个新令牌并将其添加到请求的标头中。

但是如何使用新的访问和刷新令牌更新 appsettings.json 以便将其用于后续请求。

是否有比 appsettings.json 更好的方法来存储访问和刷新令牌?

token asp.net-core refresh-token httpclientfactory

2
推荐指数
1
解决办法
3170
查看次数

令牌身份验证返回 403(Axios + Django Rest Framework)

我已经尝试解决这个问题几个小时了,如果可以的话请帮助我。

当我尝试get在 React 应用程序中使用 axios 向 DRF Rest API 发出请求时,它返回 403。

应用程序.js:

      axios
        .get(API_POSTS, {
          headers: {
            Authorization: `Token 27dbb4dd8299792c8c52022f829da4ecec22f437`
          }
        })
        .then(res => {
          console.log("Success");
        })
        .catch(error => {
          console.log(error);
        });
Run Code Online (Sandbox Code Playgroud)

设置.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    # 3rd-party apps
    'rest_framework',
    'rest_framework.authtoken',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    'rest_auth',
    'rest_auth.registration',
    'corsheaders',
    # Local
    'posts.apps.PostsConfig',
    'users.apps.UsersConfig',
]

CORS_ORIGIN_WHITELIST = [
    'http://localhost:3000',
]

# Rest Framework


REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework.authentication.BasicAuthentication' …
Run Code Online (Sandbox Code Playgroud)

token django-rest-framework reactjs

2
推荐指数
1
解决办法
1370
查看次数

Cookie 还是本地存储?

背景:我有两个应用程序前端和后端。后端是djangodjango rest framework. 对于身份验证,我使用令牌。客户端通过 登录时获取令牌post。客户端将此令牌设置为header并将令牌保留在 中localStorage。我将令牌保存到以localStorage防止重新打开站点后出现第二次请求。但我写过很多localsStorage容易受到xss攻击的文章。现在我关心的是cookies。但我不想重写我的后端逻辑。我正在考虑通过js将令牌写入cookie。

我的问题:我应该将令牌写入吗cookies?或者我应该重写我的后端应用程序并使用会话?或者mb不重写它?

javascript security cookies token local-storage

2
推荐指数
1
解决办法
3566
查看次数

如何找出给定的 Azure DevOps 令牌 (PAT) 属于哪个用户?

有时,我们会遇到 Azure DevOps 管道或使用令牌的代码段,没人知道它来自哪里。当然,这种情况不应该发生,但有时现实与理想世界有所不同。

如果我只有一个 Azure DevOps“个人访问令牌”,我如何找出它属于哪个用户?

token azure-devops

2
推荐指数
1
解决办法
2439
查看次数

VS Code:如何更改 XML 属性的颜色

如何在 Visual Studio Code 中更改XML 属性的颜色?

例如,如何为identifiant以下属性选择另一种颜色: xml样本

以下是当前的颜色主题设置:

"editor.tokenColorCustomizations": {
    "[Solarized Dark]": {
        "keywords": "#f00"
    },
    "functions": "#f5896e",
    "numbers": "#dfd51b",
    "keywords": "#215c21",
    "strings": "#67f7e3",
    "variables": "#22FF88",
    "comments": "#332244"
}
Run Code Online (Sandbox Code Playgroud)

或者更直观

色彩主题

换句话说:是否有专门适用于“XML 属性”的标记?

xml color-scheme token visual-studio-code

2
推荐指数
1
解决办法
1712
查看次数

下一个授权。如何获取谷歌id_token

简而言之:如何从 nextauth 获取 google id 令牌?

详细信息:我通过 Google 进行授权,之后我必须在服务器上验证 Google 的响应,之后服务器会将其访问令牌返回给我。一个构建后端的朋友告诉我他需要一个id_token,他会用 来检查google-auth。无论我如何尝试设置回调,我都无法获取id_token. 我只在 cookie 中获取会话令牌,没有其他任何信息。

如果可以在没有 的情况下执行此操作id_token,请也写下。

authorization token reactjs next.js next-auth

2
推荐指数
1
解决办法
4899
查看次数

为什么我必须在'using'语句之前添加额外的令牌?

Functions.h

#include <iostream>
#include <windows.h>
#include <conio.h>
#include <limits>
#include <stdexcept>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "definitions.h"
#include "globals.h"

};using namespace std;
Run Code Online (Sandbox Code Playgroud)

这是functions.h现在我们有main.cpp包括标题

Main.cpp的

#include "functions.h"

int main(int argc, char *argv[])
{
    //Other stuff
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

出于某种原因,我必须};using声明之前写.它不会让我编译,除非它在它之前.

任何想法为什么?

c++ compilation token

1
推荐指数
1
解决办法
69
查看次数

如何在数组中存储逗号分隔文件的第n列?

我有一个文件以下列格式存储数据(这只是一个小样本):

AD,Andorra,AN,AD,AND,20.00,Andorra la Vella,Europe,Euro,EUR,67627.00
AE,United Arab Emirates,AE,AE,ARE,784.00,Abu Dhabi,Middle East,UAE Dirham,AED,2407460.00
AF,Afghanistan,AF,AF,AFG,4.00,Kabul,Asia,Afghani,AFA,26813057.00
AG,Antigua and Barbuda,AC,AG,ATG,28.00,Saint John's,Central America and the Caribbean,East Caribbean Dollar,XCD,66970.00
AI,Anguilla,AV,AI,AIA,660.00,The Valley,Central America and the Caribbean,East Caribbean Dollar,XCD,12132.00
Run Code Online (Sandbox Code Playgroud)

我想存储每行的第二个字段,以便我的数组只包含国家名称,如下所示:

string countryArray[] = {"Andorra,United Arab Emirates", "Afghanistan", "Antigua and Barbuda", "Anguilla"}
Run Code Online (Sandbox Code Playgroud)

但每次运行我的代码时,都会发生分段错误.这是我的代码:

countryArray[256];

if (myfile)
{
        while (getline(myfile,line))
        {
            std::string s = line;
            std::string delimiter = ",";

            size_t pos = 0;
            std::string token;
            short loop=0;

            while ((pos = s.find(delimiter)) != std::string::npos) 
            {
                  token = s.substr(0, pos);
                  s.erase(0, pos + delimiter.length()); …
Run Code Online (Sandbox Code Playgroud)

c++ arrays string token delimiter

1
推荐指数
1
解决办法
540
查看次数

将字符串从字符串数组转换为整数

我正在尝试使用parseInt()将一些字符串从数组转换为整数.我正在阅读许多单独的文件中的行,如下所示:

car,house,548544587,645871266
Run Code Online (Sandbox Code Playgroud)

我有类似下面的代码:

String [] tokens = line.split(",");
try {
        line = line.trim();
        int a = Integer.parseInt(tokens[2]);
        int b = Integer.parseInt(tokens[3]);
        int c = (b - a);
        System.out.println(c);
        } catch (NumberFormatException e) {
                    System.out.println(e);
            }
Run Code Online (Sandbox Code Playgroud)

但是对于我读到的每一行,这都会失败并出现这样的错误:

java.lang.NumberFormatException: For input string: "548544587"
java.lang.NumberFormatException: For input string: "645871266"
Run Code Online (Sandbox Code Playgroud)

知道我可能会缺少什么吗?

java arrays string token parseint

1
推荐指数
1
解决办法
652
查看次数