Authenticate your app using session tokens

Highlighted
New Member
7 0 0

Hi guys, i want to integrate shopify app bridge with session token. I have built a shopify app in laravel.  Can anyone please help me to implement this.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
7 0 3

Hi @Tarun-web1,

What are some of the issues that you are running into? Unfortunately, we don't have an example solution using Laravel. If you haven't already, check out https://shopify.dev/tools/app-bridge/authentication for a guide on how session tokens work.

0 Likes
Highlighted

Hi @rezaansyed 

I also find it hard to implement with Python / Django. The doc is just too hard to follow:

1. How can I get session token? with this line, const sessionToken = getSessionToken(app); ?

2. I tried to install my app with Test app on development store, just click my development store. After that, it redirects to my App URL. It renders a basic template with App Bridge (added with CDN). What it shows:

  1. it redirects to my app url: https://xxxx.com/?hmac=22324ae87fc72fd24760f65956160d9ed06e08f6508ac70a6d40d3f65acd8888&shop=benny-t... .
  2. It gives Uncaught ReferenceError: getSessionToken is not defined.
  3. After that, App bridge redirects to the relative embedded URL in the Shopify admin and stops here
  4. The embedded area is showing: 

    There’s no page at this address. Check the URL and try again, or use the search bar to find what you need.

I was trying to follow the steps Load skeletons and Create app bridge client from the tutorial

The base template with app bridge:

 

 

<!DOCTYPE html>
<html>
<head>
  <title>{% block title %}Shopify Application{% endblock %}</title>
  <!-- <link href="/static/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" /> -->
</head>
<body>
  <div id="header">
    <h1><a href="{% url "index" %}">Shopify Demo Application</a></h1>
    <p id="login-link">
      {% comment %}
      {% if current_shop %}
          <span class="note">current shop</span> <a href="https://{{ current_shop.domain }}" class="shop_name">{{ current_shop.domain }}</a> <span class="note">|</span>
          <a href="{% url "shopify_app_logout" %}">logout</a>
      {% endif %}
      {% endcomment %}
    </p>
  </div>
  <div id="container" class="clearfix">
    <!-- Flash error & notice-->
    {% if messages %}
      {% for message in messages %}
      <div{% if message.tags %} class="{{ message.tags }}-message"{% endif %}>{{ message }}</div>
      {% endfor %}
    {% endif %}
    <!-- begin div.main-->
    <div id="main">
      {% block content %}{% endblock %}
    </div>
    <!-- end div.main -->
  </div>
  <script src="https://unpkg.com/@shopify/app-bridge@1"></script>
<script>
    var AppBridge = window['app-bridge'];
    var actions = window['app-bridge'].actions;
    var createApp = AppBridge.default;
    var app = createApp({
      apiKey: '{{ shopify_api_key }}',
      shopOrigin: '{{ shopname }}',
      // forceRedirect: false
    });
    const sessionToken = getSessionToken(app);
    console.log('sessionToken = ' + sessionToken);
</script>
</body>
</html>

 

 

 

SPO - SEO App to research keywords & edit social link preview
0 Likes