Menu

#1279 Error when logging in to Wekan REST API when using Sandstorm Wekan

Sandstorm
closed
nobody
2019-02-05
2017-10-07
Anonymous
No

Originally created by: xet7
Originally owned by: xet7

@kentonv

The problem is, on Standalone Wekan I can login to Wekan REST API using Wekan username and password, but on Sandstorm Wekan when I login with Google Auth, I get error with Sandstorm Webkey when I use Webkey as password. I don't know what other password I would use.

I tried this way:

1) On Wekan board create Webkey like in image by @ertanalytics
https://github.com/wekan/wekan/wiki/Wekan-Sandstorm-cards-to-CSV-using-Python

Sure by using Python BeautifulSoup etc Wekan html and javascript could probably be parsed and used like in code above, but using REST API would be much nicer.

BTW @ertanalytics when I tried to use your code this way:

sudo apt install python-pip python-bs4 python-selenium python-pandas \
python-bson chromium-chromedriver chromium-browser-l10n

sudo pip install selenium --upgrade

sudo pip install splinter

And copied chromedriver from https://sites.google.com/a/chromium.org/chromedriver/home to my /usr/bin , I got this error, do you know solution to it?

$ python cards-to-csv.py 
Traceback (most recent call last):
  File "cards-to-csv.py", line 62, in <module>
    script = soup.find("script", attrs={'type' : 'text/inject-data'}).children.next()
AttributeError: 'NoneType' object has no attribute 'children'

2) I tried to login to Wekan REST API on Sandstorm:

curl https://USERNAME:APIKEY@api-ADDRESS.SOMETHING.sandcats.io/users/login \
     -d "username=USERNAME&password=APIKEY"

3) I get curl response:

{
  "error": "internal-server-error",
  "reason": "Internal server error"
}

4) On Sandstorm Wekan board console I get this error:

Error: Unauthorized [Unauthorized]
    at Object.Authentication.checkUserId (server/authentication.js:6:21)
    at models/users.js:563:20
    at packages/simple_json-routes.js:98:9

5) But if I try some other password, I get:

{
  "error": 400,
  "reason": "Match failed"
}

Using Wekan REST API on Sandstorm could make easier:

  • uploading data from scripts etc to Sandstorm Wekan
  • have mobile apps that use Sandstorm Wekan
  • integrations with Huginn
  • incoming Webhooks, etc.

Is there some documentation how with Meteor app like Wekan it would be possible to access info outside of grain, for example so that when importing attachments from Trello, some Sandstorm-compatible way could be used to download Trello attachments to Wekan?

I have not yet tried could EtherCalc API also be used on Sandstorm.

Discussion

1 2 3 > >> (Page 1 of 3)
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: ocdtrekkie

    I noticed that the Python script pulls from Selenium. I get the impression he is actually instructing Selenium to open the full Wekan grain and operating it in an automated fashion. It's definitely vastly preferable to query the API.

    This is probably the documentation you're looking for, if you haven't seen this already: https://docs.sandstorm.io/en/latest/developing/http-apis/

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: ertanalytics

    It looks like it last worked on 9/1/2017 and after the credentials were put in it was showing the full json text data of the wekan board and the subsequent steps parsed that json data.

    The error:

    Traceback (most recent call last): File "cards-to-csv.py", line 62, in <module> script = soup.find("script", attrs={'type' : 'text/inject-data'}).children.next() AttributeError: 'NoneType' object has no attribute 'children'

    Is related to the parser not finding what it is expecting to start the parsing. Any ideas to navigate to the json data should fix this problem. Please let me know and I will update my code. I am trying a few different paths to see if I can figure out a way to get back to the json data with card titles etc. I would like all the board data if possible for the export.

    @ocdtrekkie - I am just instructing Selenium to open the URL. Once the page loads I grab the background data and immediately close the browser:

    `browser2 = Browser('chrome')

    browser2.visit(apiURLnoAuth) # Fill in the url

    sleep(1) #Time in seconds

    soup = BeautifulSoup(browser2.html,'html.parser')
    browser2.quit()`

    Once the data is assigned to the 'soup' variable, I am done with Selenium.

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: xet7

    @ertanalytics

    There is already a way to Import and Export Wekan board to and from JSON at Sandstorm Wekan, when you click board menu (hamburger icon, 3 lines) and click there Import or Export. But I don't know how to do this with API.

    Trello import on Sandstorm Wekan does not import attachments yet, because Wekan does not have Sandstorm compatible access to outside of grain. Importing Trello attachments works on Standalone Wekan (like Docker etc) and then you can export Wekan JSON that includes attachments in JSON as Base64 encoded, and then import that Wekan JSON to Sandstorm with attachments in JSON.

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: ertanalytics

    @xet7 - This appears to be broken as well in Sandstorm. The download starts, but fails 'Failed - Server problem' while download backup on Sandstorm continues to work.

    failed json export

    On 9/1/2017 and earlier, visiting the API URL had the export data readily available and that was what the script I wrote was parsing.

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: xet7

    @ertanalytics

    What version of Wekan you have on Sandstorm? Have you updated to latest? I have 0.47.0

    When updating, also update all your grains.

    Please include your Sandstorm Wekan grain console logs so I can see exact errors.

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: ertanalytics

    Version: 0.47.0

    ** SANDSTORM SUPERVISOR: Grain shutdown requested.
    ** SANDSTORM SUPERVISOR: Starting up grain. Sandbox type: userns
    ** Starting Mongo...
    2017-10-07T18:58:45.562+0000 I STORAGE Engine custom option: log=(prealloc=false,file_max=200KB)
    about to fork child process, waiting until server is ready for connections.
    forked process: 10
    child process started successfully, parent exiting
    ** Starting Meteor...
    { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
    js-bson: Failed to load c++ bson extension, using pure JS version
    Error: 59d92409a78c710200228a12 does not exist
    at Object.Future.wait (/programs/server/node_modules/fibers/future.js:449:15)
    at packages/meteor.js:213:24
    at models/export.js:85:15
    at Array.map (native)
    at Exporter.build (models/export.js:80:60)
    at models/export.js:32:62
    at packages/simple_json-routes.js:98:9

    - - - - -
    at /programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/gridfs/gridstore.js:200:22
    at /programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/collection/query.js:164:5
    at /programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/cursor.js:778:35
    at Cursor.close (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/cursor.js:1009:5)
    at Cursor.nextObject (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/cursor.js:778:17)
    at commandHandler (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/cursor.js:741:14)
    at /programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/db.js:1903:9
    at Server.Base._callHandler (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
    at /programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/connection/server.js:488:18
    at [object Object].MongoReply.parseBody (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
    at [object Object].<anonymous> (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/connection/server.js:446:20)
    at emitOne (events.js:77:13)
    at [object Object].emit (events.js:169:7)
    at [object Object].<anonymous> (/programs/server/npm/node_modules/meteor/cfs_gridfs/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13)
    at emitTwo (events.js:87:13)
    at [object Object].emit (events.js:172:7)
    
     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: xet7

    Is it only error with this Wekan grain?

    Can you export some other Wekan grain?

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: ertanalytics

    It is only happening to the one board.

    Other wekan grains are exporting json correctly.

     
  • Anonymous

    Anonymous - 2017-10-07

    Originally posted by: xet7

    I added this info to Wekan wiki

    Exporting Wekan board to JSON file with Bash script

    1) On Wekan grain, get Webkey like this:

    https://api-URL.SUBDOMAIN.sandcats.io#APIKEY
    

    2) Modity URL, SUBDOMAIN and APIKEY to this Bash script that exports board to file directly:

    curl https://Bearer:APIKEY@api-URL.SUBDOMAIN.sandcats.io/api/boards/sandstorm/export?authToken=#APIKEY > wekanboard.json
    
     
  • Anonymous

    Anonymous - 2017-10-08

    Originally posted by: kentonv

    It seems like you're successfully doing the things you need to do on Sandstorm to talk to a grain API. The errors are coming from Wekan, not Sandstorm.

    With that said, it's likely that you'll want to change the way the Wekan API is authorized on Sandstorm. Sandstorm will automatically add headers to the API requests identifying the user -- the same headers it adds to all HTTP requests. https://docs.sandstorm.io/en/latest/developing/auth/#headers-that-an-app-receives

    The X-Sandstorm-User-Id header in particular contains the Sandstorm identity ID, which matches the field services.sandstorm.id in the user record in Mongo. So you can figure out who the user is that way, instead of requiring a separate login step.

     
  • Anonymous

    Anonymous - 2017-10-11

    Originally posted by: ertanalytics

    As far as trying the Wekan API, I am not having any luck using the links through Sandstorm. The only thing that has worked was the export URL thus far. I am betting the directory structure inhibits the normal API request functions, however I am a bit green on API testing and might be missing something.

     
  • Anonymous

    Anonymous - 2017-10-17

    Originally posted by: xet7

    I think I could try to fix this by exposing /api at sandstorm-pkgdef.capnp (github.com) file when I get some free time.

     
  • Anonymous

    Anonymous - 2017-11-14

    Originally posted by: ertanalytics

    Wish I had the setup and understanding to do these changes myself. Any idea on timeline?

     
  • Anonymous

    Anonymous - 2017-11-14

    Originally posted by: xet7

    @ertanalytics

    No idea. Maybe in near or distant future.

     
  • Anonymous

    Anonymous - 2018-02-12

    Originally posted by: ertanalytics

    Following up on this one. I have reached out to xet7 to assist and he is having trouble with his sandstorm based building VM. If anyone has a working development environment to test the REST API for sandstorm version and build from it to get it to production please let me know, I would like to get this feature as soon as possible.

     
  • Anonymous

    Anonymous - 2018-02-12

    Originally posted by: xet7

    @ertanalytics

    As you can see from these IRC chatlogs, only @kentonv is currently able to build Sandstorm from source, because he made changes how Sandstorm was built:
    https://botbot.me/freenode/sandstorm/2018-02-11/?tz=Europe/Helsinki

    I don't know are there pull request to documentation yet.

    I also have not yet figured out all steps yet.

     
  • Anonymous

    Anonymous - 2018-02-12

    Originally posted by: xet7

    @ertanalytics

    Probably these fixes to build script were recently merged:
    https://github.com/sandstorm-io/sandstorm/pull/3034

     
  • Anonymous

    Anonymous - 2018-02-12

    Originally posted by: xet7

    @ertanalytics

    Add new issue to Sandstorm if you still have problems:
    https://github.com/sandstorm-io/sandstorm/issues

     
  • Anonymous

    Anonymous - 2018-02-12

    Originally posted by: xet7

    @ertanalytics

    And also add info to this issue if you get Sandstorm built, and how you did it.

     
  • Anonymous

    Anonymous - 2018-02-14

    Originally posted by: xet7

    @ertanalytics

    I added issue to Sandstorm, I still have problems.
    https://github.com/sandstorm-io/sandstorm/issues/3036

     
  • Anonymous

    Anonymous - 2018-02-21

    Originally posted by: xet7

    Install instructions included at Sandstorm repo should now work also for you.
    You can see changed merged pull requests about Docs fixes at https://github.com/sandstorm-io/sandstorm/pulls?q=is%3Apr+is%3Aclosed

    So you can clone that repo and follow instructions. It should work OK.

     
  • Anonymous

    Anonymous - 2018-03-29
     
  • Anonymous

    Anonymous - 2018-03-31

    Originally posted by: xet7

    Requirements:
    1) Add cards - including specific labels, descriptions, checklists.
    2) Move cards - from one list to another.
    3) Remove members - from the entire board.
    4) Change assignment - Assign certain members to certain cards or remove them.

     
1 2 3 > >> (Page 1 of 3)

Log in to post a comment.