Questions tagged [token]

A token is a string of characters, categorized according to the rules as a symbol (e.g., IDENTIFIER, NUMBER, COMMA). The process of forming tokens from an input stream of characters is called tokenization, and the lexer categorizes them according to a symbol type. A token can look like anything that is useful for processing an input text stream or text file.

A token is the smallest part of an input text with a meaning. A token may be a single character, a symbol, a word or anything that is useful for processing an input text. Tokens are used in processing programming languages or natural languages.

The process of forming tokens from an input stream is called tokenization or lexical analysis. A program or function which performs lexical analysis is called a lexical analyzer, lexer, or scanner.

6457 questions
538
votes
8 answers

What is token-based authentication?

I want to understand what token-based authentication means. I searched the internet but couldn't find anything understandable.
csharpbaby
  • 5,815
  • 3
  • 15
  • 12
465
votes
25 answers

Parse (split) a string in C++ using string delimiter (standard C++)

I am parsing a string in C++ using the following: using namespace std; string parsed,input="text to be parsed"; stringstream input_stringstream(input); if (getline(input_stringstream,parsed,' ')) { // do some processing. } Parsing with a…
TheCrazyProgrammer
  • 5,926
  • 7
  • 23
  • 40
175
votes
5 answers

Do login forms need tokens against CSRF attacks?

From what I've learned so far, the purpose of tokens is to prevent an attacker from forging a form submission. For example, if a website had a form that input added items to your shopping cart, and an attacker could spam your shopping cart with…
php_learner
  • 1,759
  • 2
  • 11
  • 3
169
votes
9 answers

Sending the bearer token with axios

In my react app i am using axios to perform the REST api requests. But it's unable to send the Authorization header with the request. Here is my code: tokenPayload() { let config = { headers: { 'Authorization': 'Bearer ' + validToken() …
rakibtg
  • 3,878
  • 6
  • 41
  • 63
166
votes
3 answers

How to concatenate twice with the C preprocessor and expand a macro as in "arg ## _ ## MACRO"?

I am trying to write a program where the names of some functions are dependent on the value of a certain macro variable with a macro like this: #define VARIABLE 3 #define NAME(fun) fun ## _ ## VARIABLE int NAME(some_function)(int…
JJ.
  • 1,661
  • 2
  • 11
  • 3
149
votes
3 answers

What's the difference between JWTs and Bearer Token?

I'm learning something about Authorization like Basic, Digest, OAuth2.0, JWTs, and Bearer Token. Now I have a question. You know the JWTs is being used as an Access_Token in the OAuth2.0 standard. JWTs appears at RFC 7519, and Bearer Token is at…
laoqiren
  • 2,375
  • 4
  • 15
  • 26
130
votes
4 answers

How to securely store access token and secret in Android?

I am going to use oAuth to fetch mails and contacts from google. I don't want to ask the user each time to log in to obtain an access token and secret. From what I understood, I need to store them with my application either in a database or…
yeahman
  • 2,478
  • 4
  • 16
  • 22
128
votes
1 answer

Authenticating socket io connections using JWT

How can I authenticate a socket.io connection? My application uses a login endpoint from another server (python) to get a token, how can I get use that token whenever a user opens a socket connection on the node side? io.on('connection',…
el_pup_le
  • 9,721
  • 18
  • 73
  • 126
122
votes
10 answers

Do Google refresh tokens expire?

I have used the refresh token several times in just a short period for testing purposes, but I wonder whether Google refresh tokens ever expire? Can I use the same refresh token to get another access token again and again for a long period (a week…
Robin Carlo Catacutan
  • 11,461
  • 9
  • 48
  • 79
121
votes
16 answers

How does strtok() split the string into tokens in C?

Please explain to me the working of strtok() function. The manual says it breaks the string into tokens. I am unable to understand from the manual what it actually does. I added watches on str and *pch to check its working when the first while loop…
user379888
119
votes
5 answers

Best practices for server-side handling of JWT tokens

(spawned from this thread since this is really a question of its own and not specific to NodeJS etc) I'm implementing a REST API server with authentication, and I have successfully implemented JWT token handling so that a user can login through a…
JHH
  • 6,514
  • 5
  • 28
  • 64
114
votes
2 answers

Creating C macro with ## and __LINE__ (token concatenation with positioning macro)

I want to create a C macro that creates a function with a name based on the line number. I thought I could do something like (the real function would have statements within the braces): #define UNIQUE static void Unique_##__LINE__(void) {} Which I…
DD.
  • 1,143
  • 2
  • 8
  • 4
109
votes
9 answers

Python requests library how to pass Authorization header with single token

I have a request URI and a token. If I use: curl -s "" -H "Authorization: TOK:" etc., I get a 200 and view the corresponding JSON data. So, I installed requests and when I attempt to access this resource I get a 403 probably…
user1552586
97
votes
5 answers

best practice to generate random token for forgot password

I want to generate identifier for forgot password . I read i can do it by using timestamp with mt_rand(), but some people are saying that time stamp might not be unique every time. So i am bit of confused here. Can i do it with using time stamp…
keen
  • 2,851
  • 3
  • 31
  • 57
95
votes
9 answers

https URL with token parameter : how secure is it?

On our site, we provide to users a simulation based on their private information (given through a form). We would like to allow them to get back on their simulation results later, but without forcing them to create a login/password account. We have…
Flackou
  • 3,323
  • 3
  • 25
  • 24
1
2 3
99 100