Skip to content

Commit

Permalink
Merge pull request #64 from kartverket/convertAirtableTokenToEnvVariable
Browse files Browse the repository at this point in the history
Convert airtable token to env variable
  • Loading branch information
andersstandal authored Jun 26, 2024
2 parents 2a8f57b + db60aec commit 2579210
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
1 change: 0 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ WORKDIR /app

# Copy the built jar file from the build stage
COPY --from=build /home/gradle/src/build/libs/*.jar /app/backend.jar
COPY config.properties /app/
COPY application.properties /app/

# Specify the command to run the application
Expand Down
2 changes: 2 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Set up as follows:
Working directory: <root of project>/backend
Use classpath of module: spire-kk.backend.main

Set the environment variable `AIRTABLE_ACCESS_TOKEN` in `Run -> Edit Configurations...`. You can get the value from one of your teammates.

## Run the application

To set up an IntelliJ project, New Project from existing sources -> <root directory
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/kotlin/no/bekk/AirTableController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AirTableController {
install(Auth) {
bearer {
loadTokens {
BearerTokens(accessToken, "")
BearerTokens(airtableAccessToken, "")
}
}
}
Expand Down Expand Up @@ -82,7 +82,7 @@ class AirTableController {
}
val response: HttpResponse = client.get(url) {
headers {
append("Authorization", "Bearer $accessToken")
append("Authorization", "Bearer $airtableAccessToken")
}
}
val responseBody = response.bodyAsText()
Expand Down
5 changes: 1 addition & 4 deletions backend/src/main/kotlin/no/bekk/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package no.bekk

import no.bekk.plugins.*
import io.ktor.server.application.*
import org.flywaydb.core.Flyway
import java.io.FileInputStream
import java.util.*

Expand All @@ -12,9 +11,7 @@ fun loadConfig(filePath: String): Properties {
return props
}

val props = loadConfig("config.properties")
val accessToken = props.getProperty("accessToken")

val airtableAccessToken = System.getenv("AIRTABLE_ACCESS_TOKEN")
val applicationProperties = loadConfig("application.properties")
val metadataAddress = applicationProperties.getProperty("metadataAddress")
val metodeverkAddress = applicationProperties.getProperty("metodeverkAddress")
Expand Down

0 comments on commit 2579210

Please sign in to comment.