Skip to content

Commit

Permalink
Add ShopifyApp::ShopHost to authentication docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Feb 9, 2022
1 parent d93876f commit f430d26
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions docs/shopify_app/authentication.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Authentication

The Shopify App gem implements [OAuth 2.0](https://shopify.dev/tutorials/authenticate-with-oauth) to get [access tokens](https://shopify.dev/concepts/about-apis/authentication#api-access-modes). These are used to authenticate requests made by the app to the Shopify API.
The Shopify App gem implements [OAuth 2.0](https://shopify.dev/tutorials/authenticate-with-oauth) to get [access tokens](https://shopify.dev/concepts/about-apis/authentication#api-access-modes). These are used to authenticate requests made by the app to the Shopify API.

By default, the gem generates an embedded app frontend that uses [Shopify App Bridge](https://shopify.dev/tools/app-bridge) to fetch [session tokens](https://shopify.dev/concepts/apps/building-embedded-apps-using-session-tokens). Session tokens are used by the embedded app to make authenticated requests to the app backend.
By default, the gem generates an embedded app frontend that uses [Shopify App Bridge](https://shopify.dev/tools/app-bridge) to fetch [session tokens](https://shopify.dev/concepts/apps/building-embedded-apps-using-session-tokens). Session tokens are used by the embedded app to make authenticated requests to the app backend.

See [*Authenticate an embedded app using session tokens*](https://shopify.dev/tutorials/authenticate-your-app-using-session-tokens) to learn more.
See [*Authenticate an embedded app using session tokens*](https://shopify.dev/tutorials/authenticate-your-app-using-session-tokens) to learn more.

> ⚠️ Be sure you understand the differences between the types of authentication schemes before reading this guide.
Expand Down Expand Up @@ -121,4 +121,20 @@ class AuthenticatedController < ApplicationController
end
```

See [Authenticate server-side rendered embedded apps using Rails and Turbolinks](https://shopify.dev/tutorials/authenticate-server-side-rendered-embedded-apps-using-rails-and-turbolinks) for more information.
See [Authenticate server-side rendered embedded apps using Rails and Turbolinks](https://shopify.dev/tutorials/authenticate-server-side-rendered-embedded-apps-using-rails-and-turbolinks) for more information.

### `ShopifyApp::ShopHost`

The [`ShopifyApp::ShopHost`](/app/controllers/concerns/shopify_app/shop_host.rb) concern handles fetching and caching `host` param in App Bridge 2.0 apps.

Include this concern in yours app's `SplashPageController` and `AuthenticatedController` if your app uses App Bridge 2.0. It adds `before_action` that sets `@host` variable from params or cookies and saves existing host into cookies. If host is missing in both params and cookies then `ShopifyHostNotFound` exception is raised.

*Example:*

```rb
class AuthenticatedController < ApplicationController
include ShopifyApp::ShopHost
include ShopifyApp::EnsureAuthenticatedLinks
include ShopifyApp::Authenticated
end
```

0 comments on commit f430d26

Please sign in to comment.