MCPcopy Index your code
hub / github.com/Preloading/TwitterAPIBridge / GetEncryptionKeyFromRequest

Function GetEncryptionKeyFromRequest

twitterv1/auth.go:331–350  ·  view source on GitHub ↗
(c *fiber.Ctx)

Source from the content-addressed store, hash-verified

329}
330
331func GetEncryptionKeyFromRequest(c *fiber.Ctx) (*string, error) {
332 authHeader := c.Get("Authorization")
333 // Define a regular expression to match the oauth_token
334 re := regexp.MustCompile(`oauth_token="([^"]+)"`)
335 matches := re.FindStringSubmatch(authHeader)
336
337 if len(matches) < 2 {
338 return nil, errors.New("oauth token not found")
339 }
340
341 oauthToken := matches[1]
342 oauthTokenSegments := strings.Split(oauthToken, ".")
343
344 // Get the encryption key for the data.
345 encryptionKey := oauthTokenSegments[2] + "="
346 encryptionKey = strings.ReplaceAll(encryptionKey, "-", "+")
347 encryptionKey = strings.ReplaceAll(encryptionKey, "_", "/")
348
349 return &encryptionKey, nil
350}
351
352// Checks the token is V1
353// Returns the token type

Callers

nothing calls this directly

Calls 1

GetMethod · 0.45

Tested by

no test coverage detected