4

This will be very basic, I do not know how to connect to looker with my client ID and client secret for the Looker Extension SDK. This is a hello world app but the documentation is very lacking on the basics.

import React, { useContext, useEffect, useState } from 'react'
import { ComponentsProvider, Space, Text } from '@looker/components'
import { ExtensionContext } from '@looker/extension-sdk-react'


export const HelloWorld: React.FC = () => {
  const { core40SDK } = useContext(ExtensionContext)
  const [message, setMessage] = useState('')

  useEffect(() => {
    const getMe = async () => {
      try {
        const me = await core40SDK.ok(core40SDK.me())
        setMessage('Hello, '+ me.display_name)
      } catch (error) {
        console.error(error)
        setMessage('An error occurred while getting information about me!')
      }
    }
    getMe()
  }, [core40SDK])

  return (
    <ComponentsProvider>
      <Space p="xxxxxlarge" width="100%" height="50vh" around>
        <Text p="xxxxxlarge" fontSize="xxxxxlarge">
          {message}
        </Text>
      </Space>
    </ComponentsProvider>
  )
}

This results in Failed to establish communication with Looker host, but I do not know how to establish the host url or credentials

1 Answers1

2

When you build using the Extension Framework, Looker hosts your react application internally so you don't need to do authentication. Don't use the Extension Framework if you are not hosting your react application inside Looker itself.

If you're hosting your own application and making API calls to Looker then you should just use the Looker Embed SDK. You will need to do the authentication on your webserver using nodejs / python / ruby etc. You shouldn't do authentication from client-side javascript.

Simon D
  • 5,730
  • 2
  • 17
  • 31
  • 1
    Thanks for the clarification, I just didn't understand the code examples on GitHub, thanks so much! – Josh Hendrix Jan 19 '22 at 15:33
  • No worries, you're right in saying that the Looker examples for the embed SDK are quite confusing but I believe there are some examples that show authentication. Key thing is that you need to do authentication on a backend webserver. – Simon D Jan 19 '22 at 15:36