Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Examples/flask_test_client not working #144

@hieyou1

Description

@hieyou1

Hi there,

When I try to access the Khan API thru the flask test client, it says that it "expected a signature base string." I tried fixes I found in other issues but it still isn't working. Here's the error:
KeyError: "Decoder failed to handle oauth_token with data as returned by provider. A different decoder may be needed. Provider returned: b'OAuth error. Invalid signature. Expected signature base string: POST&https%3A%2F%2Fwww.khanacademy.org%2Fapi%2Fauth2%2Frequest_token&oauth_callback%3Dhttp%253A%252F%252Flocalhost%253A5000%252Foauth_callback%26oauth_consumer_key%3DMY-KEY%26oauth_nonce%3Df8cfed8b74ebfb911d733e2ea40e5076d9260ebe%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1565700706%26oauth_version%3D1.0'"

Here's my changed khan_api file. I only remember changing the http to https, but there may be more. {Server.py left unchanged}

"""
This example script shows a possible method for integrating the Khan API into
a flask server
"""

from rauth import OAuth1Service
import requests
from flask import url_for, request, redirect, session
from time import time
import json

# You can get a CONSUMER_KEY and CONSUMER_SECRET for your app here:
# http://www.khanacademy.org/api-apps/register
CONSUMER_KEY = "MY KEY"
CONSUMER_SECRET = "MY SECRET"

# Oauth configuration values described at:
# https://github.com/Khan/khan-api/wiki/Khan-Academy-API-Authentication
SERVER_URL = "https://www.khanacademy.org"
REQUEST_TOKEN_URL = SERVER_URL + "/api/auth2/request_token"
ACCESS_TOKEN_URL = SERVER_URL + "/api/auth2/access_token"
AUTHORIZE_URL = SERVER_URL + "/api/auth2/authorize"
BASE_URL = SERVER_URL + "/api/auth2"

I have no idea what is going on. Doesn't work with PHP either (different error), but I'm not really interested in PHP.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions