cameroncros / OctoPrint-DiscordRemote

Discord plugin for OctoPrint
MIT License
68 stars 32 forks source link

API Returns 403 Forbidden Error #219

Open Dealman opened 2 years ago

Dealman commented 2 years ago

Describe the bug The API is unuseable because it requires some kind of authorization, which the documentation does not provide. Trying to use the API via Postman results in HTTP 403 Forbidden with the response "Insufficient rights".

To Reproduce

  1. Use Postman or equivalent, setup a POST following the documentation
  2. Try and send the request, receive HTTP 403 error

Expected behavior Expected to receive either the message or a sent command in Discord.

Screenshots image

cameroncros commented 2 years ago

Huh, to be honest, I have no idea about that part of the code, it worked when I wrote it, but that was a long time ago.

https://docs.octoprint.org/en/master/api/general.html

I suspect that doco is relavent to setting up the authentication, can you try it and confirm?

Dealman commented 2 years ago

Had a quick gander at it, it now returns the message Failed to send message with a 404 NOT FOUND response code.

Edit:

Seems like it may be working after allowing CORS and rebooting.

Dealman commented 2 years ago

image

Was able to use the API to provide thumbnails, however it's limited to rather small sizes due to the 6000 character limit. 128x128 is a pretty nice size, but results in ~6300 characters. Attached is a size of 92x92.

Any chance this limit could be increased?

cameroncros commented 2 years ago

The character limit applies to strings, you can instead attach the images the same way snapshots are attached, and then it shouldn't matter about the 6000 char limit? I'm not 100% sure how your sending the images to be honest.

On Sat, 30 Apr 2022, 9:24 pm Dennis, @.***> wrote:

[image: image] https://user-images.githubusercontent.com/7038067/166103499-2edde0c3-fdba-4b78-9706-0a7f72102ca9.png

Was able to use the API to provide thumbnails, however it's limited to rather small sizes due to the 6000 character limit. 128x128 is a pretty nice size, but results in ~6300 characters. Attached is a size of 92x92.

Any chance this limit could be increased?

— Reply to this email directly, view it on GitHub https://github.com/cameroncros/OctoPrint-DiscordRemote/issues/219#issuecomment-1113971255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7FLZ37YNI6UDTYSJLCPLVHUJ7PANCNFSM5UWTK6PA . You are receiving this because you commented.Message ID: @.***>

cameroncros commented 2 years ago

Oh, sorry, your talking about the Web api and sending messages that way? That might require some changes in that case. How are you sending the images to the api? Can you show me the data you are sending?

On Sat, 30 Apr 2022, 9:32 pm Cameron Cross, @.***> wrote:

The character limit applies to strings, you can instead attach the images the same way snapshots are attached, and then it shouldn't matter about the 6000 char limit? I'm not 100% sure how your sending the images to be honest.

On Sat, 30 Apr 2022, 9:24 pm Dennis, @.***> wrote:

[image: image] https://user-images.githubusercontent.com/7038067/166103499-2edde0c3-fdba-4b78-9706-0a7f72102ca9.png

Was able to use the API to provide thumbnails, however it's limited to rather small sizes due to the 6000 character limit. 128x128 is a pretty nice size, but results in ~6300 characters. Attached is a size of 92x92.

Any chance this limit could be increased?

— Reply to this email directly, view it on GitHub https://github.com/cameroncros/OctoPrint-DiscordRemote/issues/219#issuecomment-1113971255, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7FLZ37YNI6UDTYSJLCPLVHUJ7PANCNFSM5UWTK6PA . You are receiving this because you commented.Message ID: @.***>

Dealman commented 2 years ago

This is how I sent the above image;

{
    "command": "sendMessage",
    "title": "Title",
    "description": "Message",
    "image": "iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAYAAADj79JYAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAMFklEQVR4nO2be3BcVR3Hv79z7+7m0TZN05A+UhuSUKCEbHgNVRHrOMprKK0z1SkiooOvcdSiIx2fHf/wNYAIg4PAMA4M8qgIWCyICNRuKlZbiyFgk+bRPDbZPJqkbbKPe+49P/+4u9nNZvPebWDmfDIn2ce95/x+3/M7v3PuuTeARqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDQajUajed9Di23AQnlkd3X50sKC7xO4DgSwonclcNfndjU0AcBT99Ssc2zBt+xq6F5sW4H3ueDf+0Z1ae3a/KMlRcbaMxEFpYDCPMJYlIfOhNV/833kZ2AFAWMMuvPmXQ0PAuDFtPl9KfhjP7ugxEPC3zPI12ys9N559WX5KCj1AgRYQxKHG6N4q9lCSZEx4TwivMaOdfuO7x07sTiWv8cF370bYkPhhVUe4fE7iv2GoDpm9gMoBxMNn3EA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fkvhNm2xjz9BNdvxwWWsZYuebhvyA4IxYGxWOzg8PDwqWz5kQtyNr/dtq3yF4X5YtfWq5egMH/6LZvU5RiQeYI71iFxvEOeaQnKN0dGnYDjcCAUCh0CEM2VD7kgpwuK27ZVPlq81PjijR8pRJ4vLnrqbux4akimjMQEd6xDoqVLDrR0W/XhGAeUQqC3t/coAGdSQ+8jcir45s0w1xdX/XHVCmPLlqsL3eZ44pLAneAsHDshuaVbdrUG7QO2VPUOcyAUCv0PZ3EFcTbI+ZJ5+/by/CW2769fuHHZVUIQ+odsHOuQONZhqZYu2dQVkgdYod4BDvT29nbm2p7F5qxco9y2tWJ5abH3vtePRC4InbQPKoUAM9eHQqGBs9G+RqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDQajUaj0WSV/wPxTk/z+BaDMwAAAABJRU5ErkJggg==",
    "imagename": "Thumbnail.png"
}

Also, the color parameter I wasn't able to make use of at all. Are you sure it's meant to be in the format of 0x######?

cameroncros commented 2 years ago

Does it fail if you send a larger image? The 6000 char thing only applies to text (it's a discord limit, not mine).

Not sure about the colour thing, did you try sending the hex as a number as well as a string? One of them should have worked.

"color": 0xAABBCC,

Vs

"Color": "0xAABBCC",

Or maybe:

"Color": "AABBCC", ?

On Sat, 30 Apr 2022, 9:36 pm Dennis, @.***> wrote:

This is how I sent the above image;

{ "command": "sendMessage", "title": "Title", "description": "Message", "image": "iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAYAAADj79JYAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAMFklEQVR4nO2be3BcVR3Hv79z7+7m0TZN05A+UhuSUKCEbHgNVRHrOMprKK0z1SkiooOvcdSiIx2fHf/wNYAIg4PAMA4M8qgIWCyICNRuKlZbiyFgk+bRPDbZPJqkbbKPe+49P/+4u9nNZvPebWDmfDIn2ce95/x+3/M7v3PuuTeARqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDQajUajed9Di23AQnlkd3X50sKC7xO4DgSwonclcNfndjU0AcB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7E3Gdkmjokt/VYPce75YFIVNU7Dgf6+voaMWnazB1Z9f/zW8/9pBDixWs3FXgzPSqcCzKtIE6NOmjqkGjqsLg9aB8/3i0DilW9lOpAf39/21kxbAqyHnCf31q5w+OhJ274UKEoLc6W6JxMDcm37jecmOAkmjotpy1oN3T2ygAT11uWExgYGAhlyYiskJMRfuvWym8V+MS9N36kkJYvSfkvhNm2xjz9BNdvxwWWsZYuebhvyA4IxYGxWOzg8PDwqWz5kQtyNr/dtq3yF4X5YtfWq5egMH/6LZvU5RiQeYI71iFxvEOeaQnKN0dGnYDjcCAUCh0CEM2VD7kgpwuK27ZVPlq81PjijR8pRJ4vLnrqbux4akimjMQEd6xDoqVLDrR0W/XhGAeUQqC3t/coAGdSQ+8jcir45s0w1xdX/XHVCmPLlqsL3eZ44pLAneAsHDshuaVbdrUG7QO2VPUOcyAUCv0PZ3EFcTbI+ZJ5+/by/CW2769fuHHZVUIQ+odsHOuQONZhqZYu2dQVkgdYod4BDvT29nbm2p7F5qxco9y2tWJ5abH3vtePRC4InbQPKoUAM9eHQqGBs9G+RqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDQajUaj0WSV/wPxTk/z+BaDMwAAAABJRU5ErkJggg==", "imagename": "Thumbnail.png" }

Also, the color parameter I wasn't able to make use of at all. Are you sure it's meant to be in the format of 0x######?

— Reply to this email directly, view it on GitHub https://github.com/cameroncros/OctoPrint-DiscordRemote/issues/219#issuecomment-1113972688, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7FL4B4KUZNHNTOXI2XYTVHULMLANCNFSM5UWTK6PA . You are receiving this because you commented.Message ID: @.***>

Dealman commented 2 years ago

Ah, I stand corrected. It does work with larger files, I guess when I tried last time it failed to reach for one reason or another. Tried just now with a 256x256 thumbnail and it worked just fine and dandy.

As for the color, the parameter name needs to be Color and value a string. However I don't see any changes in color anywhere in the message.

image

Edit:

Tried to use hexadecimal color as well, it does post and return a 204 - but no color changes seen anywhere.

cameroncros commented 2 years ago

Sorry, I have been busy, so not really following this much, but the colour field if it was working would affect that yellow strip on the left of the embeds in the screenshot you supplied. afaik, it should work, but I haven't looked at it deeply yet

Dealman commented 1 year ago

Might as well update this as I've started getting back into 3D printing, the correct format is just a straight-up integer. As seen listed here.

The plugin itself uses hex in the format of 0x00AE86, this format is incompatible when using as the API as is #00AE86. The API expects an integer, not a string. In order for this to be compatible with the API, the format needs to be "color" = 44678.

IMO this is very counter intuitive, and seems like an oversight/mistake?

I might look into this after I'm done trying to implement #218.

Edit:

Error for future reference;

TypeError: Expected discord.Colour, int, or Embed.Empty but received str instead.
2022-11-26 14:48:30,402 - octoprint.server.api - ERROR - Error while executing SimpleApiPlugin discordremote
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/server/api/__init__.py", line 158, in pluginCommand
    response = api_plugin.on_api_command(command, data)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1688, in wrapper
    return f(*args, **kwargs)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_discordremote/__init__.py", line 349, in on_api_command
    return self.unpack_message(data)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_discordremote/__init__.py", line 377, in unpack_message
    self.discord.send(messages=builder.get_embeds())
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_discordremote/embedbuilder.py", line 194, in get_embeds
    embeds.append(embed.get_embed())
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_discordremote/embedbuilder.py", line 275, in get_embed
    timestamp=datetime.utcnow())
  File "/home/pi/oprint/lib/python3.7/site-packages/discord/embeds.py", line 115, in __init__
    self.colour = colour
  File "/home/pi/oprint/lib/python3.7/site-packages/discord/embeds.py", line 230, in colour
    raise TypeError('Expected discord.Colour, int, or Embed.Empty but received %s instead.' % value.__class__.__name__)
TypeError: Expected discord.Colour, int, or Embed.Empty but received str instead.
cameroncros commented 1 year ago

Ah, thanks for finding that. It might be a simple fix in that case, use int() as described by https://stackoverflow.com/a/209550

Dealman commented 1 year ago

Ah, thanks for finding that. It might be a simple fix in that case, use int() as described by https://stackoverflow.com/a/209550

I'll check it out for sure, I'm currently trying to figure out how to build this. First time touching plugin development for OctoPrint, so I'm currently just uploading a .zip file over and over again - it refuses to accept me linking to my forked repo.

Any suggestions on how to set up the build environment properly? 😅

cameroncros commented 1 year ago

If you've forked the repo, there is the test.sh script in the top of the directory that you can use to spin up a virtual environment with octoprint and the plugin installed. itll also spawn a webbrowser pointed at octoprint.

Is that suitable for testing?

It used to work for windows with git bash, but it'll probably work best under Linux.

Otherwise if you want to test in on your live octoprint, I normally SSH to my octoprint server, active the oprint venv (source oprint/bin/activate), clone my git repo, and the run python setup.py install to install the plugin into the oprint venv.

Dealman commented 1 year ago

Thank you, that should help 👍