getUserInfo
  :: MonadIO m
  => Manager
  -> Provider
  -> AccessToken
  -> ExceptT (Maybe ByteString) m Text
getUserInfo mgr provider token = do
  let endpoint = identityEndpoint provider
  (withExceptT Just $ ExceptT $ liftIO $ authGetJSON mgr token endpoint) >>=
    (maybe (throwE Nothing) pure . lookupProviderInfo)
  where
    lookup' a b = maybeText =<< M.lookup a b
    maybeText (String x) = Just x
    maybeText _ = Nothing
    lookupProviderInfo = lookup' (identityField provider)
getUserInfo
  :: MonadIO m
  => Manager
  -> Provider
  -> AccessToken
  -> ExceptT (Maybe ByteString) m Text
getUserInfo mgr provider token = do
  let endpoint = identityEndpoint provider
  (withExceptT Just $ ExceptT $ liftIO $ authGetJSON mgr token endpoint) >>=
    (maybe (throwE Nothing) pure . lookupProviderInfo)
  where
    lookup' a b = maybeText =<< M.lookup a b
    maybeText (String x) = Just x
    maybeText _ = Nothing
    lookupProviderInfo = lookup' (identityField provider)
getUserInfo mgr provider token = do
  let endpoint = identityEndpoint provider
  (withExceptT Just $ ExceptT $ liftIO $ authGetJSON mgr token endpoint) >>=
    (maybe (throwE Nothing) pure . lookupProviderInfo)
  where
    lookup' a b = maybeText =<< M.lookup a b
    maybeText (String x) = Just x
    maybeText _ = Nothing
    lookupProviderInfo = lookup' (identityField provider)