-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question]: account impersonation auth flow #212
Comments
This is the modification I did to my fork to bypass a token refresh and use the impersonated access token diff --git a/lib/gogol/src/Gogol/Auth.hs b/lib/gogol/src/Gogol/Auth.hs
index bbe4e40b8..054e019f5 100644
--- a/lib/gogol/src/Gogol/Auth.hs
+++ b/lib/gogol/src/Gogol/Auth.hs
@@ -183,6 +183,13 @@ exchange c l = fmap (Auth c) . action l
FromClient x n -> exchangeCode x n
FromUser u -> authorizedUserToken u Nothing
FromTokenFile f -> \_l _m -> readTokenFile f
+ FromAccountImpersonation accessToken tokenExpiry ->
+ \_logger _manager ->
+ pure $ OAuthToken
+ { _tokenAccess = accessToken,
+ _tokenRefresh = Nothing,
+ _tokenExpiry = tokenExpiry
+ }
-- | Refresh an existing 'OAuthToken'.
refresh ::
@@ -200,6 +207,13 @@ refresh (Auth c t) l = fmap (Auth c) . action l
FromClient x _ -> refreshToken x t
FromUser u -> authorizedUserToken u (_tokenRefresh t)
FromTokenFile f -> \_l _m -> readTokenFile f
+ FromAccountImpersonation accessToken tokenExpiry ->
+ \_logger _manager ->
+ pure $ OAuthToken
+ { _tokenAccess = accessToken,
+ _tokenRefresh = Nothing,
+ _tokenExpiry = tokenExpiry
+ }
-- | Apply the (by way of possible token refresh) a bearer token to the
-- authentication header of a request.
diff --git a/lib/gogol/src/Gogol/Internal/Auth.hs b/lib/gogol/src/Gogol/Internal/Auth.hs
index 9eaba956e..2a246f75b 100644
--- a/lib/gogol/src/Gogol/Internal/Auth.hs
+++ b/lib/gogol/src/Gogol/Internal/Auth.hs
@@ -71,6 +71,7 @@ data Credentials (s :: [Symbol])
-- of the Google CloudSDK Tools.
FromUser !AuthorizedUser
| FromTokenFile !FilePath
+ | FromAccountImpersonation !AccessToken !UTCTime
-- | Service Account credentials which are typically generated/download
-- from the Google Developer console of the following form: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I use this library to make impersonated requests? Here's an example of what I want to do
From what I've gathered so far I need to generate a token with
Gogol.IAMCredentials.Projects.ServiceAccounts.GenerateAccessToken.newIAMCredentialsProjectsServiceAccountsGenerateAccessToken
. I assume I need to construct aCredential
using the access token I got. I tried constructing itauthToAuthorizedUser
but it fails because it requires a refresh token. Any help would be appreciatedThe text was updated successfully, but these errors were encountered: