Fixed OAuth 2.0 key bug and refactored cryptography code