Hit the Firebase Dynamic Links API in Python

Introduction

Official documentation was available, and I think it's okay if you follow the basics, but it's a bit clogged. There was also a point, so I will summarize it with a memo.

procedure

Firebase settings

Log in from Firebase console. Check the API KEY of Firebase. Then move to the project settings. Enter the following values for iOS and Android from "Add App" to add. The following are all required.

iOS

App ID Prefix is used because the apple-app-site-association for Universal Link is generated behind the scenes.

Android

Check the domain of Firebase Dynamic Links

I will add it appropriately. If you get any error here, you made a mistake in adding the app. When you add a link, the following domain should be displayed in the upper left of the link list table, so make a note of it (important). https://xxx.app.goo.gl/

Try hitting from Python

import requests


url = "https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=FIREBASE_API_KEY"
data = {
    "dynamicLinkInfo": {
        "dynamicLinkDomain": "xxx.app.goo.gl",
        "link": "http://example.com/",
        "androidInfo": {
            "androidPackageName": "com.example.AndroidApp"
        },
        "iosInfo": {
            "iosBundleId": "com.example.iOSApp"
        }
    }
}
result = requests.post(url, json=data)

If result.ok is true, you are successful. If successful, you'll find the URL in result.json ().

Where I was sober

You can't find the domain mentioned above without adding one Dynamic Links on the Firebase console (maybe you just missed it). So, at first, the domain of dynamicLinkDomain in the above code example is [firebase project name] .app.goo.gl? When I tried it, I got the following error

{
	'error': {
		'code': 400, 
		'message': 'Request contains an invalid argument.', 
		'status': 'INVALID_ARGUMENT'
	}
}

I didn't know what was wrong and I was exhausted.

Well, other people may not get stuck, but I was inadvertently worried. I wrote it in the hope that it would help someone.

that's all.

Recommended Posts

Hit the Firebase Dynamic Links API in Python
Hit the Sesami API in Python
Hit the web API in Python
Getting the arXiv API in Python
[Python] Hit the Google Translation API
Hit the Etherpad-lite API with Python
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Tweet using the Twitter API in Python
Try hitting the YouTube API in Python
An easy way to hit the Amazon Product API in Python
Hit the New Relic API in Python to get the server status
Try using the BitFlyer Ligntning API in Python
Evernote API in Python
Tips for hitting the ATND API in Python
C API in Python 3
Try using the DropBox Core API in Python
PHP and Python samples that hit the ChatWork API
Using the National Diet Library Search API in Python
Download the file in Python
Find the difference in Python
Blender Python API in Houdini (Python 3)
Call the API with python3.
Get your heart rate from the fitbit API in Python!
Hit a command in Python (Windows)
Python in the browser: Brython's recommendation
Save the binary file in Python
Get the desktop path in Python
Get the script path in Python
In the python command python points to python3.8
Implement the Singleton pattern in Python
Create Gmail in Python without API
Use the Flickr API from Python
I wrote the queue in Python
Calculate the previous month in Python
Examine the object's class in python
Get the desktop path in Python
Quickly implement REST API in Python
The first step in Python Matplotlib
I wrote the stack in Python
Master the weakref module in Python
Regularly upload files to Google Drive using the Google Drive API in Python
Firebase Authentication token issuance in Python and token verification with Fast API
Python beginners hit the unofficial API of Google Play Music to play music
Play by hitting the Riot Games API in Python First half
Try using FireBase Cloud Firestore in Python for the time being
Learn the design pattern "Prototype" in Python
Learn the design pattern "Builder" in Python
Mouse operation using Windows API in Python
Load the remote Python SDK in IntelliJ
Check the behavior of destructor in Python
Learn the design pattern "Flyweight" in Python
Learn the design pattern "Observer" in Python
Learn the design pattern "Memento" in Python
Learn the design pattern "Proxy" in Python
Write the test in a python docstring
Learn the design pattern "Command" in Python
OR the List in Python (zip function)
[FX] Hit oanda-API in Python using Docker
Display Python 3 in the browser with MAMP
Learn the design pattern "Visitor" in Python