def sound_cloud_petition_resolved(handler): """ Getting back from redirection of SoundCloud and getting Access_Token :param code: Code extracted from the URL that SoundCloud Redirect (Default) """ code = handler.get_argument('code') sound_cloud_client = Clients().sound_cloud_client() access_token = sound_cloud_client.exchange_token(code) current_user = sound_cloud_client.get('/me').username DANaix.initialize_client(current_user, access_token.access_token) return "ok" # Improve messages. Change to Json
def instantiate_user(user_id): """ Creates a SoundCloud Client with his access token (searching in the DB) :param user_id: The user who is performing the action Note: Not a petition. Just internal functions to avoid DRY """ access_token = DANaix.get_client_token(user_id) sound_cloud_client = Clients().sound_cloud_client(access_token=access_token) return sound_cloud_client