Created
April 13, 2019 13:29
-
-
Save mikepyts/2d99e6b6663be7f876100029bb1dc980 to your computer and use it in GitHub Desktop.
Authentificate and authorize to Google APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Access scopes | |
private val accessScope = listOf("https://www.googleapis.com/auth/cloud-platform.read-only") | |
private var token = "Empty" | |
// Receive Google OAuth 2 token for API access | |
private fun authenticateAndAuthorize() { | |
doAsync { | |
val googleCredential = GoogleCredential | |
.fromStream(ctx.assets.open("service-account.json")) | |
.createScoped(accessScope) | |
googleCredential.refreshToken() | |
this@BigQueryAPI.token = googleCredential.accessToken | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment