-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] add guides for bookingsync omniauth app #209
base: master
Are you sure you want to change the base?
Conversation
|
||
## Adding OmniAuth and integrating BookingSync | ||
|
||
Go to the [BookingSync Partners section](https://www.bookingsync.com/en/partners/login) and register you account or sign in if you already have one. After you sign in, create a new application. You will need to the provide a name, an admin URL (the URL to which the user should be redirected to after signing in when developing `embedded` application) and a redirect URI. Here's an example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
register you
... > your
<img alt="BookingSync" src="/images/bookingsync_new_application.png"> | ||
</div> | ||
|
||
In this case we want to have a separate application, not the one that should be accessible only from the applications' store, so `standalone` application is the way to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why, no reasons to have a standalone application if you can embedded it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you want to have embedded application? If it's separate from BookingSync ecosystem, you would probably want to have it standalone instead of embedding, no? Or maybe I don't get the use case, but can't really think why it would be better to have embedded application here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the UX of users is greatly improved with Embedded applications. This keeps your management on single window and keep BookingSync sidebar small on the left.
<%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br /> | ||
<%- end -%> | ||
<% end -%> | ||
~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't properly formatted on the Readme page. Is this a comment? Please refer the rendered page https://github.com/BookingSync/bookingsync-api-docs/blob/fb1069e6f88e69a07936a094d2bae1a64c512c42/content/guides/set-up-rails-appplication-with-omniauth-bookingsync.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a comment, it's a part of the docs, just not sure why it doesn't really work for html / erb.
end | ||
~~~ | ||
|
||
For the sake of example we added extra `rentals_read` scope besides `public` which is always included. You can learn more about available scopes [here](http://developers.bookingsync.com/reference/authorization/#scopes). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public
is not included by default anymore, but SHOULD be requested on the scopes list.
|
||
You can get both the application and app secret in partners section. | ||
|
||
Now we need to generate some migrations for handling authentication process. To keep it simple here, we will add it to the `Account` model directly, but you will probably want to have a separte to-one relationship with other model like `BookingSyncAcount`. The details how the process works is beyond the scope of this guide, you can learn more about it [here](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separte
> separate
|
||
`Account#remote_rentals` method is responsible for fetching `rentals` from the API and it simply delegates the logic to `bookingsync_api_client`. The API client requires `oauth_token`, which is returned in `token` method. This method also ensures that the token will also be valid - if the token expires, it will perform a proper request using `refresh_token` to get a new one. Fetching tokens requires properly configured `oauth_client` with the right headers and application's data. | ||
|
||
And that's it! Now you can sign in, click the link to connect your account with BookingSync, perform authorization and after redirecting back to you app you should see a list of rentals (if you have created any). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
back to you
app > your
No description provided.