Created
June 6, 2020 16:34
-
-
Save nakanoasaservice/241687ecb5219ae0ce633a884d8ab5bb to your computer and use it in GitHub Desktop.
Firebase Authorizationからトークンを発行する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from pprint import pprint | |
| CONFIG = { | |
| "apiKey": "YOUR API KEY", | |
| "authDomain": "YOURPROJECTID.firebaseapp.com", | |
| "databaseURL": "https://YOURPROJECTID.firebaseio.com", | |
| "projectId": "YOUR PROJECT ID", | |
| "storageBucket": "YOUR PROJECT ID.appspot.com", | |
| "messagingSenderId": "YOUR MESSAGE SENDER ID", | |
| "appId": "YOUR:APP:ID", | |
| "measurementId": "YOUR MEASUREMENT ID" | |
| } | |
| EMAIL = 'test001@example.com' | |
| PASSWORD = 'password' | |
| def main(): | |
| api_key = CONFIG["apiKey"] | |
| uri = f"https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key={api_key}" | |
| data = {"email": EMAIL, "password": PASSWORD, "returnSecureToken": True} | |
| result = requests.post(url=uri, data=data) | |
| user = result.json() | |
| pprint(user) | |
| print(user['idToken']) | |
| if __name__ == '__main__': | |
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {'displayName': '', | |
| 'email': 'test001@example.com', | |
| 'expiresIn': '3600', | |
| 'idToken': 'YOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKEN', | |
| 'kind': 'identitytoolkit#VerifyPasswordResponse', | |
| 'localId': 'YOURLOCALID', | |
| 'refreshToken': 'YOURREFRESHTOKENYOURREFRESHTOKENYOURREFRESHTOKENYOURREFRESHTOKENYOURREFRESHTOKENYOURREFRESHTOKENYOURREFRESHTOKEN', | |
| 'registered': True} | |
| YOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKENYOURIDTOKEN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment