MCPcopy Create free account
hub / github.com/oauthlib/oauthlib / generate_token

Function generate_token

oauthlib/common.py:188–197  ·  view source on GitHub ↗

Generates a non-guessable OAuth token OAuth (1 and 2) does not specify the format of tokens except that they should be strings of random characters. Tokens should not be guessable and entropy when generating the random characters is important. Which is why SystemRandom is used inste

(length=30, chars=UNICODE_ASCII_CHARACTER_SET)

Source from the content-addressed store, hash-verified

186
187
188def generate_token(length=30, chars=UNICODE_ASCII_CHARACTER_SET):
189 """Generates a non-guessable OAuth token
190
191 OAuth (1 and 2) does not specify the format of tokens except that they
192 should be strings of random characters. Tokens should not be guessable
193 and entropy when generating the random characters is important. Which is
194 why SystemRandom is used instead of the default random.choice method.
195 """
196 rand = SystemRandom()
197 return ''.join(rand.choice(chars) for x in range(length))
198
199
200def generate_signed_token(private_pem, request):

Callers 4

create_code_verifierMethod · 0.90
test_generate_tokenMethod · 0.90
generate_client_idFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_generate_tokenMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…