Skip to content

Commit

Permalink
[TF] put api keys in separate file
Browse files Browse the repository at this point in the history
This makes it easier to manage them as the don't need to be weirdly
quoted.
And they are now .gitignored so accidentally committing them should be
harder.
  • Loading branch information
Marcus Hoffmann committed Nov 30, 2017
1 parent 8c8499c commit eb2a17b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ TMessagesProj/.externalNativeBuild/
TMessagesProj/libs
3rdParty/download
3rdParty/unpacked
API_KEYS
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ MTproto protocol manuals: https://core.telegram.org/mtproto
```
4. If you want to publish a modified version of Telegram:
- You should get **your own API key** here: https://core.telegram.org/api/obtaining_api_id and update the file `TMessagesProj/build.gradle` accordingly.
Something like this will work, note the double quoting of the APP_HASH value:
- You should get **your own API key** here: https://core.telegram.org/api/obtaining_api_id and create a file called `API_KEYS` in the root source directory.
The contents should look something like this:
```
buildConfigField 'int', 'APP_ID', "12345"
buildConfigField 'String', 'APP_HASH', '"aaaaaaaabbbbbbccccccfffffff001122"'
APP_ID = 12345
APP_HASH = aaaaaaaabbbbbbccccccfffffff001122
```
- Do not use the name Telegram and the standard logo (white paper plane in a blue circle) for your app — or make sure your users understand that it is unofficial
- Take good care of your users' data and privacy
Expand Down
16 changes: 14 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ dependencies {
implementation 'org.osmdroid:osmdroid-android:5.6.5'
}

//return an api key from a properties file.
def getAppId(){
Properties properties = new Properties()
properties.load(new FileInputStream("./API_KEYS"))
return properties.get("APP_ID")
}
def getAppHash(){
Properties properties = new Properties()
properties.load(new FileInputStream("./API_KEYS"))
return "\"" + properties.get("APP_HASH") + "\""
}

android {
compileSdkVersion 25

Expand Down Expand Up @@ -144,8 +156,8 @@ android {
versionName "4.2.1"

//obtain your own keys at https://core.telegram.org/api/obtaining_api_id
buildConfigField 'int', 'APP_ID', AppId
buildConfigField 'String', 'APP_HASH', AppHash
buildConfigField 'int', 'APP_ID', getAppId()
buildConfigField 'String', 'APP_HASH', getAppHash()

externalNativeBuild {
ndkBuild {
Expand Down

0 comments on commit eb2a17b

Please sign in to comment.