Skip to main content

Accessing Original Authentication Tokens

For advanced integrations, you may need direct access to the original authentication tokens from music streaming services. This is useful when you need to call music service APIs directly for functionality not yet supported by MusicAPI.

Backend Implementation (Client Secret Authentication)

Use Case

Access original authentication tokens when you need to make direct API calls to music streaming services for unsupported endpoints or advanced functionality.

Endpoint

GET /public/integrations/user/{userModelUUID}

Example Request

Retrieve User Authentication Data
curl "https://api.musicapi.com/public/integrations/user/e892f4a5-887f-4df5-9062-f8e3fff8c68a" \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Authorization: Basic [BASE64_ENCODED_CLIENT_CREDENTIALS]'

Example Response

Authentication Data Response
{
"integrationUser": {
"integrationUserId": "1163433669",
"userUUID": "e892f4a5-887f-4df5-9062-f8e3fff8c68a",
"name": "Bartosz Hernas",
"email": "[email protected]",
"imageUrl": "https://example.com/profile-image.jpg",
"country": "pl",
"authData": {
"accessToken": "REDACTED_FOR_SECURITY"
},
"authDataExpiresAt": 1696320099094
}
}

Security Requirements

Backend Only

This endpoint requires Client Secret authentication and must only be called from your secure backend servers. Never expose Client Secret credentials in frontend code.

From your frontend - using oneTimeToken

If you frontend app has a need to save the original auth tokens, and you do not have your own backend, you can request the login page with additional parameter: requestOneTimeToken set to true.

Now in the returned data64 param, it will contain one additional property, oneTimeToken:

Parsed Data Param
{
"integration": {
"type": "spotify",
"returnUrl": "https://api.musicapi.com/callback/spotify"
},
"authModel": {
"uuid": "6fe4e706-ebe3-40b2-aa0f-f74177aa8708",
"status": "success",
"error": null
},
"integrationUserUUID": "e75315f0-d1e1-4063-b801-181ad1a954e1",
"oneTimeToken": "e50cc5e7-254a-4cff-a000-457ae53a059d"
}

You can use it only once to fetch the auth data and it expires in 1 minute, so make sure to use it immediately. Just pass the token in Authorization header as Token {oneTimeToken}.

Fetch User Auth Data Request with one time token
curl "https://api.musicapi.com/public/integrations/user/e892f4a5-887f-4df5-9062-f8e3fff8c68a" -H 'Content-Type: application/json; charset=utf-8' -H 'Authorization: Token e50cc5e7-254a-4cff-a000-457ae53a059d'