Skip to content

Message.token must be a non-empty string. #365

@maelfosso

Description

@maelfosso

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Ubuntu
  • Library version: firebase-admin 3.0.0 on Python 3.6.8
  • Firebase Product: messaging (auth, database, storage, etc)

[REQUIRED] Step 3: Describe the problem

I'm trying to send a notification to an user.
I don't know why but I'm alway getting the error Message.token must be a non-empty string

Relevant Code:

app = get_app()
driver_uuid = self.validated_data['driver'].user.id
print('\nDRIVER UUID \n', driver_uuid)
registration_token = auth.create_custom_token(str(driver_uuid))
print('\nREGISTRATION TOKEN \n\t', registration_token)
message = messaging.Message(
            notification = messaging.Notification(
                body = json.dumps({
                    "status": "test"
                }),
                title = "Title"
            ),
            data = {
                'score': '850',
                'time': '2:45',
            },
            token=registration_token
        )
try:
            response = messaging.send(message, app=app)
            # Response is a message ID string.
            print('\nSuccessfully sent message:', response)
        except Exception as e:
            print('\nEXCEPTION... EX \n')
            print(e)

        except messaging.ApiCallError as ex:
            response = ex.detail.response # This is a requests.Response object
            response_data = response.text # Read the response as a string
            print('\nEXCEPTION API CALL ERROR ...\n')
            print('\t', reponse, '\n')
            print('\n\t', response_data, '\n')

Console

DRIVER UUID 
 f1990efc-0d6b-4128-a58b-d481d181bdac

REGISTRATION TOKEN 
	 b'eyJ0eXAiOiAiSldUIiwgImFsZyI6ICJSUzI1NiIsICJraWQiOiAiMDg4ZjE4ODkwZmNiNzE3MjI0ZmM5YzljOWFjNDA1NWEwZWI3YzBkYSJ9.eyJpc3MiOiAiZmlyZWJhc2UtYWRtaW5zZGstd2hxajhAdGF4aS05ODk1Ny5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsICJzdWIiOiAiZmlyZWJhc2UtYWRtaW5zZGstd2hxajhAdGF4aS05ODk1Ny5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsICJhdWQiOiAiaHR0cHM6Ly9pZGVudGl0eXRvb2xraXQuZ29vZ2xlYXBpcy5jb20vZ29vZ2xlLmlkZW50aXR5LmlkZW50aXR5dG9vbGtpdC52MS5JZGVudGl0eVRvb2xraXQiLCAidWlkIjogImYxOTkwZWZjLTBkNmItNDEyOC1hNThiLWQ0ODFkMTgxYmRhYyIsICJpYXQiOiAxNTczNjU4ODA3LCAiZXhwIjogMTU3MzY2MjQwN30.CB9CRJ0DsE8ccktbbwPOaG2WOaTEHmER790OTQi02d8Cy0wH3V-qrfwVeshG5TprmoPE0p1-d88Z_fiYIwM1AQvuRLW5G0xsGSjBVE-gBqgtUhiDf-f0ZmdzCuSVF2o-dFeKcLU6hQKca6DLh70XnwxgnhD4YIaTQU-QkzNmhfc8X_l0dSQzjiqVk6rSuxRHP_lo-0YkkFF7VdugOga9k6Q3TWfbc5AtAavkruzSnLj8urXtpAzftrFFMLgAusMxP4IgYDAIm7J1YUB0-5iVsf8YInsb2rijV83KXqJg5_Tj_r0cN1SgdRya22i6YTEFm47thJ8BYnEy9PiPox3_nA'

EXCEPTION... EX 

Message.token must be a non-empty string.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions