Skip to content
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

Google.runGoogle doesn't exist anymore #180

Open
tonyalaribe opened this issue Aug 15, 2022 · 1 comment
Open

Google.runGoogle doesn't exist anymore #180

tonyalaribe opened this issue Aug 15, 2022 · 1 comment

Comments

@tonyalaribe
Copy link

Google.runGoogle doesn't exist anymore, but the docs still point to it for executing commands, and it's not clear what the new alternative should be.

@mklinik
Copy link

mklinik commented Oct 18, 2023

It is send now, in line with amazonka. After a while of tinkering I came up with this. GoogleOptions is just a record with some Text and FilePath. Our key is in a .pem file.

helloGogol :: GoogleOptions -> Text -> IO ()
helloGogol gOpts purchaseToken = do
  privKey <- readKeyFile (googleKeyFile gOpts) >>= \case
    [] -> error "no key found"
    x:_ -> case x of
      Unprotected (PrivKeyRSA key) -> return key
      Unprotected _ -> error "not an RSA key"
      Protected _ -> error "protected key"
  let logger = \_ _ -> return ()
  let credentials = Gogol.FromAccount $ Gogol.ServiceAccount
        { _serviceId = Gogol.ClientId ""
        , _serviceEmail = googleServiceAccount gOpts
        , _serviceKeyId = googleKeyId gOpts
        , _serviceAccountUser = Nothing
        , _servicePrivateKey = privKey
        }
  manager <- Gogol.newManager Gogol.tlsManagerSettings
  env <- Gogol.newEnvWith @'[Android.Androidpublisher'FullControl] credentials logger manager
  subscription <- Gogol.runResourceT $ Gogol.send env $ Android.newAndroidPublisherPurchasesSubscriptionsv2Get (googleAppPkgName gOpts) purchaseToken
  print subscription

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants