Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The sample app callback uri is not compliant with the Procore API. #4

Open
perrinromney opened this issue Aug 13, 2022 · 0 comments
Open

Comments

@perrinromney
Copy link

The Procore API reference states that the only http callback URI that is acceptable is "http://localhost". The sample app uses a callback URI of "http://localhost:3000/users/home" which is rejected by the Procore API at runtime. In order to fix this I had to add the code below into the oath_main file:

callbackapp = Flask(__name__)

@callbackapp.route('/',methods=["GET", "POST"])
def app_callback1():
    if request.method == "GET":
        if session.get('bool') is False:
            code = request.args.get('code')
            cburl= f'{REDIRECT_URI}?code={code}'
    return redirect(cburl)

and then run a separate python script to run it before spinning up the main server on port 3000, coded as follows:

from oauth_main import callbackapp

#------- Runs the callback application ------
callbackapp.run(debug=True, port=80)

I then had to change all functions that were sending a callback URI to Procore to use http://localhost, which I just hardcoded since it isn't optional.
these functions were:

  • make_authorization_url()
  • get_token(code)

The issues are twofold:

  1. The Procore-Official sample app doesn't follow Procore's requirements for callback URIs and therefore is not a currently functioning sample
  2. The Procore API does not recognize endpoints at http://localhost/[ENDPOINT HERE] or on other ports. This should be changed to allow any endpoint or port on the local machine - it is far too limiting and clumsy to have to listen on port 80 while running everything else on a different port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant