Using JWT Session token in CodeIgniter

Using JWT Session token in CodeIgniter

GreenReceipt
Shopify Partner
8 0 1

Hi,

I want to add authentication in my app with session tokens as per shopify requirement, but unable to find a single source to implement session tokens functionality in my codeigniter app. Is there someone who created shopify embeded app using codeigniter and also implements the authentication process with session tokens?

If yes kindly provide some sample code or give idea how we can implement this.

Replies 2 (2)

Liam
Shopify Staff
2823 310 805

Session tokens are JSON Web Tokens that Shopify generates and are used to authenticate requests between your app and Shopify's API, so you may need a a JWT library to handle JWT operations. Here's a general overview of how you could implement Auth in CodeIgniter:

  • OAuth Redirect: In your controller, create a method to redirect users to Shopify's authorization URL with the necessary parameters (client_id, scopes, redirect_uri, etc.).
  • Handle OAuth Callback: Implement a method to handle the callback from Shopify. Use this to exchange the code for an access token and request a session token.
  • Session Token Storage: Store the session token in the user's session (using CodeIgniter's session library) or in a secure, accessible manner for subsequent API requests.

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

GreenReceipt
Shopify Partner
8 0 1

Thankyou for your reply,

I have some more doubts, how we handle this on frontend (view) using app bridge and also can you please elaborate Handle OAuth Callback, like after OAuth Redirect , it will redirected to generate access token function so when and how this exchange the code works like how i can request session token. All the functions are set i have to only embed this session token functionality so where i have to add and what endpoints have to use. Please give a detail.