question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add OAuth2/Space client authentication

See original GitHub issue

Subsystem Client

Is your feature request related to a problem? Please describe. There is no oauth2 client authentication, and especially JetBrains Space auth

Describe the solution you’d like I’d like to have smth like

val spaceClient = client.config {
    Auth {
       Space(clientId, clientSecret) 
    }
}

actually to authenticate in Space I have to do smth like

private data class AccessToken(val token_type: String, val expires_in: Int, val access_token: String)

private suspend fun issueAccessToken(endpoint: String, clientId: String, clientSecret: String): AccessToken {
        return client.submitForm(
            url = "${endpoint}/oauth/token",
            formParameters = Parameters.build {
                append("grant_type", "client_credentials")
                append("scope", "**")
            }
        ) {
            header(
                HttpHeaders.Authorization,
                HttpAuthHeader.Single(
                    AuthScheme.Basic,
                    String(Base64.getEncoder().encode("$clientId:$clientSecret".toByteArray()))
                ).render()
            )
        }
    }

and later on for each query use

private fun HttpRequestBuilder.authHeader() {
        header(
            HttpHeaders.Authorization,
            HttpAuthHeader.Single(issueAccessToken.token_type, issueAccessToken.access_token).render()
        )
    }

Motivation to include to ktor OAuth2 is quite common auth way

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
fullkomnuncommented, Jan 7, 2021

Is there any update regarding this issue?

1reaction
hardysimcommented, Oct 28, 2020

To crosslink the progress:

  • #1740 contains the OAuthAuthProvider but was only merged into a private branch by @e5l
  • #1733 contains an additional constant AuthScheme.Bearer which is needed by OAuthAuthProvider but is not merged yet
  • I’ve used both in production since I’ve posted both and they’re working fine so I’d be happy if both can me accepted and added to the master-branch.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using OAuth 2.0 for Server to Server Applications | Authorization
If you have a Google Workspace account, an administrator of the organization can authorize an application to access user data on behalf of...
Read more >
Add Authentication To Your iOS Apps with Centralized Login
In this tutorial we implement centralized logins for iOS both manually and using the Auth0 SDK.
Read more >
AM 6 > OAuth 2.0 Guide - ForgeRock Backstage
In the AM console, navigate to Realms > Realm Name > Applications > OAuth 2.0. Click Add Client, and then provide the Client...
Read more >
The OAuth2 Filter | Edge Stack
OAuth client settings · "HeaderPassword" : Treat the client secret (below) as a password, and pack that in to an HTTP header for...
Read more >
OAuth 2.0 Client Authentication - Takahiko Kawasaki - Medium
In traditional ways, to begin with, an authorization server generates a pair of client ID and client secret and gives the pair to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found