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

Fix Auth step 5 by using Content-Type: application/x-www-form-urlencoded #111

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

maorcc
Copy link
Contributor

@maorcc maorcc commented Jun 9, 2024

User description

What changes do you are proposing?

Fix Auth step 5 error 400: "Bad request. Accept and/or Content-Type headers likely do not match supported values."

How did you test these changes?

Manually tested

Closing issues


PR Type

Bug fix


Description

  • Fixed Auth step 5 error 400 by changing the request body format from raw JSON to application/x-www-form-urlencoded.
  • Updated body parameters to be URL-encoded to match the required Content-Type header.

Changes walkthrough 📝

Relevant files
Bug fix
IEC.postman_collection.json
Fix Auth step 5 by changing request body format to urlencoded

IEC.postman_collection.json

  • Changed the request body mode from raw JSON to urlencoded.
  • Updated the body parameters to use application/x-www-form-urlencoded
    format.
  • +28/-7   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    PR Review 🔍

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are localized to a single JSON configuration file and involve a straightforward conversion of the request body format from JSON to URL-encoded. The changes are not complex and are easy to understand.

    🧪 Relevant tests

    No

    ⚡ Possible issues

    Possible Bug: Ensure that all necessary URL-encoded parameters are correctly set and that no required parameters are missing or incorrectly named, as this could lead to functional issues.

    🔒 Security concerns

    No

    Copy link

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Add a Content-Type header to ensure the server correctly interprets the request body

    Consider adding a Content-Type header with the value application/x-www-form-urlencoded to
    ensure the server correctly interprets the request body.

    IEC.postman_collection.json [403-432]

    +"header": [
    +  {
    +    "key": "Content-Type",
    +    "value": "application/x-www-form-urlencoded"
    +  }
    +],
     "body": {
       "mode": "urlencoded",
       "urlencoded": [
         {
           "key": "client_id",
           "value": "{{appClientId}}",
           "type": "text"
         },
         {
           "key": "code_verifier",
           "value": "{{VERIFIER}}",
           "type": "text"
         },
         {
           "key": "grant_type",
           "value": "authorization_code",
           "type": "text"
         },
         {
           "key": "redirect_uri",
           "value": "com.iecrn:/",
           "type": "text"
         },
         {
           "key": "code",
           "value": "{{oauthCode}}",
           "type": "text"
         }
       ]
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding a Content-Type header is a best practice when changing the body mode to urlencoded, as it ensures that the server interprets the request body correctly. This suggestion addresses a significant aspect of HTTP communication that was overlooked in the PR.

    8
    Possible issue
    Ensure all variables in the urlencoded body are properly defined and have valid values

    Ensure that all variables used in the urlencoded body are properly defined and have valid
    values in the environment or collection variables to prevent runtime errors.

    IEC.postman_collection.json [406-429]

    +{
    +  "key": "client_id",
    +  "value": "{{appClientId}}",
    +  "type": "text"
    +},
    +{
    +  "key": "code_verifier",
    +  "value": "{{VERIFIER}}",
    +  "type": "text"
    +},
    +{
    +  "key": "grant_type",
    +  "value": "authorization_code",
    +  "type": "text"
    +},
    +{
    +  "key": "redirect_uri",
    +  "value": "com.iecrn:/",
    +  "type": "text"
    +},
    +{
    +  "key": "code",
    +  "value": "{{oauthCode}}",
    +  "type": "text"
    +}
     
    -
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: This suggestion is relevant as it ensures that all variables used in the new urlencoded body are properly defined, which is crucial for preventing runtime errors. The suggestion correctly identifies the new code and its potential issues.

    7

    @GuyKh
    Copy link
    Owner

    GuyKh commented Jun 9, 2024

    Thanks @maorcc -- did you test it out?

    @maorcc
    Copy link
    Contributor Author

    maorcc commented Jun 9, 2024

    @GuyKh, Yes, of course, I tested it. It works now.

    @GuyKh GuyKh merged commit 37a164e into GuyKh:main Jun 10, 2024
    1 check passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    2 participants