Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

GitHub raw file download from a Private repo


Question

Posted

Hello guys

 

Can anyone help me with a Http request, that would fetch a certain file from a certain private repository?

I was trying to use token, byt probably i malformed my HTTP call.

Any help please?

 

So far i tried these two ways, 

 

Way one, according to documentatin, there is a link for raw files with token 

 

Please login or register to see this link.

 

I have tried this inside a regula http call like

 

Please login or register to see this code.

 

this did not work

 

Then i tried with headers in the HTTP call

 

Please login or register to see this code.

 

 

this neither

 

 

Anyone can help please?

 

THanks

Recommended Posts

  • 0
Posted

I think you need the use the GitHub API with a PAT token, see: 

Please login or register to see this link.

 

This example is with CURL, in the HC3 it should look like:

Please login or register to see this code.

 

More information about how HTTP requests are made in HC3

Please login or register to see this link.

.

  • Like 1
  • 0
  • Inquirer
  • Posted

    Hello Joep, thanks for your help. I will look into it and give it a try.

    • 0
  • Inquirer
  • Posted
    8 minutes ago, Joep said:

    I think you need the use the GitHub API with a PAT token, see: 

    Please login or register to see this link.

     

    This example is with CURL, in the HC3 it should look like:

    Please login or register to see this code.

     

    More information about how HTTP requests are made in HC3

    Please login or register to see this link.

    .

    I think this refers to whole repositories, and not to single raw file, anyway, i will try to dig more into this direction, becasue i think it can be very similar to this..Thanks again

    • 0
    Posted (edited)
    2 minutes ago, Neo Andersson said:

    I think this refers to whole repositories, and not to single raw file

    This is an example for an asset. With the API you can also specify a file as I know. 

     

     

    From the documentation at 

    Please login or register to see this link.

    :

     

    Please login or register to see this link.

     

     

    Edited by Joep
    add documentation link
    • 0
  • Inquirer
  • Posted
    Just now, Joep said:

    This is an example for an asset. With the API you can also specify a file as I know. 

    Probably yes..I need to study the API part quite a bit, as i never worked with it. Thanks

    • 0
    Posted

    No problem. I edited my post with some helpfull links ;)

    • 0
  • Inquirer
  • Posted
    1 minute ago, Joep said:

    No problem. I edited my post with some helpfull links ;)

    Thanks again for your help

    • 0
    Posted

    I have seen somewhere that these tokens (shown as part of the raw download url from a private repo) are only valid for a limited time - like 7 days.

    • 0
  • Inquirer
  • Posted (edited)

    I have tried up an down, and i found a way it works.

    Just use the regular token, set expiracy to infinit, and use the regular raw file donwload url

     

    Please login or register to see this code.

     

    Now i need to find a way to auto update a quickapp from github.

    I am half the way now, ..i can fetch the fqa file, extract files from it, and post these content back to  quickapp files..

    I need to delete the file first, then post with the new content, and restart the QA, as there is no option for modifyinig the file.

    The only thing i need to figure out, is the version control.

    As when i do a raw file donwload, it does not contain any info about versions (github releases), so i think i need to place a piece of code into files top line, like

    "Version 3", and after the download happens, i will parse the file and check that first line. Seem to me very midle aged but i dont have any other solution now.

    Edited by Neo Andersson
    • 0
    Posted (edited)

    what I do in my qa updater is that I download files from the repo from a given tag.

    the tag effectively becomes the version.

    I also have a separate updater qa - because when qa's update themselves and it fails or is a bug they can't recover. 

    the qa updater can roll-back the failed qa to an earlier version(earlier tag).

    I also create a manifest.json file with mapping from QA versions to repo tags (I have many different QAs the QA updater handles). 

    I'm a bit unsure how this work with encrypted QAs...

    Edited by jgab
    • 0
  • Inquirer
  • Posted
    2 minutes ago, jgab said:

    what I do in my qa updater is that I download files from the repo from a given tag.

    the tag effectively becomes the version.

    I also have a separate updater qa - because when qa's update themselves and it fails or is a bug they can't recover. 

    the qa updater can roll-back the failed qa to an earlier version(earlier tag).

     

    I'm a bit unsure how this work with encrypted QAs...

    I have to check how to donload raw file with a given TAG.  Never did it so far.

    The biggest problem for me, is tp update a QA for a user, wihtout affecting its ID and some files in it. 

    The only way seemed to me is, like i described abouve.

    Download files that we want to update. Extract their content. Make a post back to the file on HC3.

    But the problem is, i can't get it work, as when a delete the old file from HC3, it deletes some functions that are called from that file, so QA stops, and doesnt finish the upload

    of the new file (where that function ofcourse exists, but QA can't get to it, as the file is deleted. ) I can't only modify the file, then restart the QA. Or can I ?

    I can't find the way to update ceratin file in QA. Any suggestioni please?

    • 0
    Posted (edited)
    14 minutes ago, Neo Andersson said:

    I have to check how to donload raw file with a given TAG.  Never did it so far.

    The biggest problem for me, is tp update a QA for a user, wihtout affecting its ID and some files in it. 

    The only way seemed to me is, like i described abouve.

    Download files that we want to update. Extract their content. Make a post back to the file on HC3.

    But the problem is, i can't get it work, as when a delete the old file from HC3, it deletes some functions that are called from that file, so QA stops, and doesnt finish the upload

    of the new file (where that function ofcourse exists, but QA can't get to it, as the file is deleted. ) I can't only modify the file, then restart the QA. Or can I ?

    I can't find the way to update ceratin file in QA. Any suggestioni please?

    It almost doomed to let the qa update itself. You can update several files in one swoop but there will always be corner cases where you need to add new files or remove files that leave your qa in a bad state (every time you write the qa restarts) - and then of course there could be bugs in your new code…

    that’s why I have a separate qa that updates my other qas and let the user roll- back if something went wrong.

    Edited by jgab
    • 0
    Posted

    I assume your qa is not encrypted?

    …don’t store the repo token in an unencrypted qa….

    • 0
  • Inquirer
  • Posted
    1 minute ago, jgab said:

    I assume your qa is not encrypted?

    …don’t store the repo token in an unencrypted qa….

    yet not encrypted, until i am testing..

    Later will encrypt it ofcourse, however, it is a huge questionmark for me, how will it work when encrypted..

    The file structure works the same way, as in unencrypted mode? Probably yes, but i dont know..

    So can i later downoload a file content, and upload a new content to a encrypted QA file system?

    A lot of work for me to be done, as i am not that great expert as you, so i am really greatfull for any help for all of you

    • 0
    Posted (edited)

    The problem with encrypted qas is that I assume I can’t upgrade their files from another qa, like I currently do. And letting the qa update itself (assuming an encrypted qa can manipulate its own “file system”) is too error prone.

     

    I had a time when my EventRunner would upgrade itself - a total mess when something went wrong and I had to ask users to download old version and manually move over configurations from the crashed to the new. And of course they got a new device I’d then…

    Edited by jgab
    • 0
  • Inquirer
  • Posted
    1 hour ago, jgab said:

    The problem with encrypted qas is that I assume I can’t upgrade their files from another qa, like I currently do. And letting the qa update itself (assuming an encrypted qa can manipulate its own “file system”) is too error prone.

    Jan, regasrding your TAG based version control...It is one thing that i can get somehow the info from my Repo about its latest version (get from these tags somehow), but how do

    you store information in your QA file sitting in HC3 about their current version? I mean if you don't store any version info in your FIbaro files, then every time you release a new version, 

    it must be applied to every system that your QA is running on, regardless of their current version. Do you have some trick, how to compare the version on HC against the version on Github?

    • 0
    Posted

    Yes, I put a unique serial number for the QA + a version number in the model property of the QA (it's a string)

    My Updater QA looks through all QAs with a model property that conform to that format and can then determine

    what QA it is (serial number) and what version it is (version number)

    Then I have a manifest.json in GitHub that maps serial number and version -> GitHub tag.

    Then I fetch the relevant files from that tag for a given version.

     

    The manifest also contains what files to add, remove and keep for a given QA, and version.

     

    I also have a magic script that generates the manifest semi-automatically when I have to push a new version (I have the data in  manifest.lua file that is tweaked to an updated manifest.json file)

     

    It may be of little help but the Updater QA is in my repo in jgabs_QAs (just called Updater)

    • 0
  • Inquirer
  • Posted
    2 minutes ago, jgab said:

    Yes, I put a unique serial number for the QA + a version number in the model property of the QA (it's a string)

    My Updater QA looks through all QAs with a model property that conform to that format and can then determine

    what QA it is (serial number) and what version it is (version number)

    Then I have a manifest.json in GitHub that maps serial number and version -> GitHub tag.

    Then I fetch the relevant files from that tag for a given version.

     

    The manifest also contains what files to add, remove and keep for a given QA, and version.

     

    I also have a magic script that generates the manifest semi-automatically when I have to push a new version (I have the data in  manifest.lua file that is tweaked to an updated manifest.json file)

     

    It may be of little help but the Updater QA is in my repo in jgabs_QAs (just called Updater)

    Thanks Jan

    • 0
    Posted

    Does it work when you use main in a QA to just do the init, update handling and launch the QA code in another file?

     

    So a function in main downloads the new version file and replaces the old. Does this crash or cripple the QA? 
     

    I have an update notifier via GitHub, buts in a public repo. On my list is this auto update mechanism. I know somebody has written it on the forum, but I forgot the user. 

    • 0
  • Inquirer
  • Posted
    1 minute ago, Joep said:

    Does it work when you use main in a QA to just do the init, update handling and launch the QA code in another file?

     

    So a function in main downloads the new version file and replaces the old. Does this crash or cripple the QA? 
     

    I have an update notifier via GitHub, buts in a public repo. On my list is this auto update mechanism. I know somebody has written it on the forum, but I forgot the user. 

    As Jgab mentioned, it is not working within the same QA that you want to update.  At this moment i am able to upate a some file in QA2 from a function in QA1. So when a press a button (for testing i use a button, later i will make it automatic), it goes to github, fetches the quickapp file with fqa extension, then extraxt all files from it, and finds the file that i want to update. Then it delets the old file, uploads the new file into QA2. This is working now. Now i need to implement some version logic, and find out if this will work with fqax extensions too. probably not. You cant self update the file. It doesnt work. I need to call the update from another file.

     

     

     

     

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...