Skip to content

Instantly share code, notes, and snippets.

@YuzuRyo61
Created November 14, 2018 09:29
Show Gist options
  • Save YuzuRyo61/ddfd237bbd55717b663c953a541ce258 to your computer and use it in GitHub Desktop.
Save YuzuRyo61/ddfd237bbd55717b663c953a541ce258 to your computer and use it in GitHub Desktop.
MisskeyでApiトークンを作成するためのPythonスクリプト。対話式なので簡単に作成できます。pyperclipライブラリを導入しているとクリップボードにもコピーできます。
Copyright 2018 YuzuRyo61
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Misskey ApiToken Generator v 1.0
Coding by YuzuRyo61.
Licenced under MIT.(Please read the 'LICENSE')
"""
import hashlib
try:
import pyperclip
iscbEnabled = True
except ImportError:
print("**WARNING**: Python library is not found: 'pyperclip'")
print("You cannot copy to clipboard. However, You can run this script.")
iscbEnabled = False
if __name__ == "__main__":
accessToken = input("accessToken: ")
appSecret = input("appSecret: ")
rawapitoken = accessToken + appSecret
apitoken = hashlib.sha256(rawapitoken.encode('utf-8')).hexdigest()
print("apiToken is: \n{}".format(apitoken))
if iscbEnabled == True:
isCopyTClip = None
while isCopyTClip == None:
isCopyTClipANS = input("Would you like to copy to clipboard?(y/n)").lower()
if isCopyTClipANS in ['y']:
isCopyTClip = True
elif isCopyTClipANS in ['n']:
isCopyTClip = False
if isCopyTClip == True:
pyperclip.copy(apitoken)
print("Copyed! Check clip:{}".format(pyperclip.paste()))
else:
input("[ENTER TO EXIT...]")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment