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

Function StoreToken

db_controller/db_controller.go:153–168  ·  view source on GitHub ↗

StoreToken stores an encrypted access token and refresh token in the database. It returns the UUID of the stored token or an error if the operation fails. Parameters: - did: The decentralized identifier of the user. - accessToken: The access token to be encrypted and stored. - refreshToken: The ref

(did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64)

Source from the content-addressed store, hash-verified

151// - The UUID of the stored token.
152// - An error if the operation fails.
153func StoreToken(did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64) (*string, error) {
154 // Check if token exists for this DID.
155 // Generate new UUID for new token
156 uuid, err := uuid.NewRandom()
157 if err != nil {
158 return nil, err
159 }
160
161 // Update or create token
162 finalUUID, err := UpdateToken(uuid.String(), did, pds, accessToken, refreshToken, encryptionKey, accessExpiry, refreshExpiry, 2)
163 if err != nil {
164 return nil, err
165 }
166
167 return finalUUID, nil
168}
169
170func UpdateToken(uuid string, did string, pds string, accessToken string, refreshToken string, encryptionKey string, accessExpiry float64, refreshExpiry float64, tokenVersion int) (*string, error) {
171 encryptedAccess, err := authcrypt.Encrypt(accessToken, encryptionKey)

Callers 1

access_tokenFunction · 0.92

Calls 1

UpdateTokenFunction · 0.85

Tested by

no test coverage detected