# Private Github for Library \[SOLVED\]

**URL:** <https://forum.defold.com/t/private-github-for-library-solved/67240>\
**Category:** Questions\
**Created:** [January 11, 2021, 8:49pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240 "2021-01-11T20:49:38Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [January 11, 2021, 8:49pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/1 "2021-01-11T20:49:38Z")

</div>

Hello,

I’ve got a team of 2 others working with me on a project which requires a few different games being developed. We are at the point where I want to start using libraries shared between us, but not at the point where I want to make the projects publicly accessible.

It seems that this is possible if we have setup personal access tokens ([Working with library projects in Defold](https://defold.com/manuals/libraries/)) however I was hoping to get more details on how we set this up with defold when fetching libraries? If each of the developers has a private access token for their github accounts setup then will they be able to fetch any repos that they have access to?

Any help you can provide on this is greatly appreciated.

Cheers,  
Spen

---

<div class="post-metadata">

**Author:** ![Jb\_Skaggs](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/jb_skaggs/32/22828_2.png) [@Jb\_Skaggs](https://forum.defold.com/u/Jb_Skaggs)\
**Post date:** [January 11, 2021, 10:24pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/2 "2021-01-11T22:24:18Z")

</div>

Was going to ask a similar question. I have had problems with the personal tokens and a private library looking forward to a solution.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 11, 2021, 10:31pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/3 "2021-01-11T22:31:02Z")

</div>

I posted additional information in the Libraries manual:

> **[Basic access authentication - Working with library projects in Defold](https://defold.com/manuals/libraries/#basic-access-authentication)**
>
> The Libraries feature allows you to share assets between projects. It is a simple but very powerful mechanism that you can use in your workflow in a number of ways. | The Libraries feature allows you to share assets between projects. This manual...

---

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [January 11, 2021, 11:31pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/4 "2021-01-11T23:31:57Z")

</div>

Wow, that was quick, thank you very much for the quick update.

The level of thought put into Defold is seriously one of the big positives for it.

Cheers,  
Spen

---

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [February 3, 2021, 10:09am UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/5 "2021-02-03T10:09:42Z")

</div>

I’ve been thinking about this, and the only problem is I don’t want my github username and access token to be in the project. To your knowledge is there any way to ensure the username and access token aren’t shared with others working on the project?

When creating an access token on Github you setup it’s access. But you can’t setup “Can only pull this one repo” which I would be fine with being accessible to others. All you can setup is “Can completely access all private repositories you have access to” or none. At least that’s my understanding. Any assistance with this would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [February 3, 2021, 11:40am UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/6 "2021-02-03T11:40:57Z")

</div>

You should be able to use environment variables. Can you test that?

---

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [February 3, 2021, 11:44am UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/7 "2021-02-03T11:44:28Z")

</div>

Our approach to this was to create a separate github user and add it with read access to only the relevant repos. Also the token was generated as read-only access. This access token was safe to push to the Interrogation repo, since it only provided access to repos needed for building Interrogation.

---

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [February 3, 2021, 12:01pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/8 "2021-02-03T12:01:58Z")

</div>

Thank you for your response @dapetcu21

How do you generate read only access for the tokens? I can’t see how you would do this with the scope options provided?

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/9/1/910048fa5b09a2995d5f9530aa142b413d698a0b.png)

@Pkeod thank you for responding, to be clear, you mean have the username and access token as environment variables on my computer whilst I press “fetch libraries”?

---

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [February 3, 2021, 12:04pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/9 "2021-02-03T12:04:38Z")

</div>

Oh. I was under the impression that there’s an option. I’m mistaken then. Anyway, you should be fine if you only give read permissions to the user when you add it to your private repo.

---

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [February 3, 2021, 12:48pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/10 "2021-02-03T12:48:00Z")

</div>

Cannot seem to use environment variables unless I’m setting them up wrong.

I’ve got a terminal where I run Defold from. Before running defold in that terminal I created the environment variables:  
GIT\_USERNAME=‘\<username\>’  
GIT\_TOKEN=‘\<token\>’  
Then the included libary was [https://GIT\_USERNAME:GIT\_TOKEN@github.com/\](https://GIT_USERNAME:GIT_TOKEN@github.com/%5C)/\<repo\>/archive/main.zip  
Now when I use just the contents of the environment variables in place of those environment variables it does work.

Is there any mistakes I’m making in accessing these environment variables from Defold?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [February 3, 2021, 1:03pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/11 "2021-02-03T13:03:50Z")

</div>

> [@SpencerWF](#):
>
> [https://GIT\_USERNAME:GIT\_TOKEN@github.com/&lt;username&gt;/&lt;repo&gt;/archive/main.zip](https://GIT_USERNAME:GIT_TOKEN@github.com/&lt;username&gt;/&lt;repo&gt;/archive/main.zip)

We don’t replace environment variables into that string (would be a nice feature).

What if you use environment variables, and the dependency without auth arguments?

> [https://github.com/&lt;username&gt;/&lt;repo&gt;/archive/main.zip](https://github.com/&lt;username&gt;/&lt;repo&gt;/archive/main.zip)

Also note that we check for the auth arguments first in the path, then use the `X-Email` and `X-Auth` as fallback. ([code](https://github.com/defold/defold/blob/dev/com.dynamo.cr/com.dynamo.cr.bob/src/com/dynamo/bob/Project.java#L1230-L1248)). The latter two are only available via bob.jar (“–email” and “–auth”).

---

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [February 3, 2021, 1:23pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/12 "2021-02-03T13:23:11Z")

</div>

I’m sorry I don’t understand what you are suggesting here? How would I use environment variables in the dependency path without Auth arguments? Just running it without any Authentication does not pull in the repo since it is private. I tried using the ssh version of the repo as I have ssh keys setup on github, but that didn’t work either.

How do I setup X-Email and X-Auth?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [February 3, 2021, 2:03pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/13 "2021-02-03T14:03:46Z")

</div>

I was merely referring to what @pkeod mentioned. But I too am not sure why the environment variables would work in this situation.

As for the other --email/–auth properties, you have to use [bob.jar](https://defold.com/manuals/bob/#usage) via command line.

---

<div class="post-metadata">

**Author:** ![SpencerWF](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/spencerwf/32/21158_2.png) [@SpencerWF](https://forum.defold.com/u/SpencerWF)\
**Post date:** [February 3, 2021, 8:22pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/14 "2021-02-03T20:22:55Z")

</div>

Going through the other options here, your solution seems to be the only one that really solves all of my problems completely. To be honest I wanted to avoid creating a new account, but at this point it seems to work fairly well and won’t scare my less command line savvy team mates.

If going through this process would be useful on a tutorial or showcase or something let me know.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [February 3, 2021, 10:08pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/15 "2021-02-03T22:08:03Z")

</div>

> [@SpencerWF](#):
>
> If going through this process would be useful on a tutorial or showcase or something let me know.

I think it will be useful to other teams working on larger projects with private dependencies! The manual could use improvements:

> **[Basic access authentication - Working with library projects in Defold](https://defold.com/manuals/libraries/#basic-access-authentication)**
>
> The Libraries feature allows you to share assets between projects. It is a simple but very powerful mechanism that you can use in your workflow in a number of ways. | The Libraries feature allows you to share assets between projects. This manual...

And we’d happily accept a guest blog post / tutorial here: [Defold blog](https://defold.com/blog/)

---

<div class="post-metadata">

**Author:** ![Ahmutkadim](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ahmutkadim/32/33104_2.png) [@Ahmutkadim](https://forum.defold.com/u/Ahmutkadim)\
**Post date:** [January 24, 2024, 3:59pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/16 "2024-01-24T15:59:47Z")

</div>

Hi, I am just wondering whether it is possible to use ssh keys for authenticating to fetch libraries. It would be easier than setting up access tokens.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 24, 2024, 10:17pm UTC](https://forum.defold.com/t/private-github-for-library-solved/67240/17 "2024-01-24T22:17:00Z")

</div>

> [@Ahmutkadim](#):
>
> I am just wondering whether it is possible to use ssh keys for authenticating to fetch libraries. It would be easier than setting up access tokens.

No, I’m afraid this isn’t supported.
