Sign in with Hey.Café📚 Developer Resources
We want to make things easy and thats why we are working on many ways to connect to an account and provide easy sign in. So for this we have added the ability to allow users to sign in to your service using a Hey.Café account. ### Sign in with button ### This helper script will generate a Sign in with button where it’s placed, and will auto encode the information you provide for the request. It will also use the current url if you have the URL variable set to false. Source is non minified and can easily be read or copied. `` <script src='https://hey.cafe/application/external/sign_in_with.js' publisher='NodeHost' reason='Account sign in and access' url='false'></script> `` ### Making the request ### ---- This part is easy, send the person to this URL structure. You do need to replace ` PUBLISHER ` ` REASON ` and ` SENDBACK ` with your own data in base64 encoding to be url safe for all 3 options listed. You can easily do this in most languages or pre make the URL values using an online encoder like the following. https://www.base64encode.org `` hey.cafe/request/auth/PUBLISHER/REASON/SENDBACK `` Data you need to provide PUBLISHER: is your application or website name. REASON: is a simple message that will say why the session is needed like “For quick and easy sign in”. SENDBACK: is a url to send the user to when done, we do append ` ?key=KEY ` to your URL when sending them back (if already using url variables we change it according), you need this key to validate the account and to get basic account info when done. ---- ### Checking the access and getting user data ### ---- Now that the user is back on your site you can validate the auth token sent back in ` ?key=KEY ` by calling the following URL. If the key is not valid system_api_error will have the value ` notvalid `. `` endpoint.hey.cafe/api/account_key?query=KEY `` ** What to keep and store ** The user can change all details on Hey.Café except the account id. This will always be the same and the value you should store for the linked account. The best way would be once the user is sent back is to store the auth key that is provided in the url variable ` key ` and call the API endpoint to validate the key and get the user ID. You don’t need to store the key as the user data can be updated on the fly using the API call ` /api/account_info ` to auto update things like the account avatar photo or more. Keep in mind you may need to store the ` key ` as later on we will be adding ways to interact with the user by sending them emails or even notifications VIA our service. Note the The key expires on each sign in This key is linked to your ` PROVIDER ` and the ` SENDBACK ` value so make sure you keep this the same each time, otherwise the user will see a buildup of sessions in settings for your service. ---- ### Request permissions like location or email ### ---- You can make a request once you have the key to ask the user for the ability to see their email address, or even location (country and state) if say needed for example if you need location to provide tax rates for billing reasons. Send the person to this URL structure. You do need to replace ` key ` ` TYPE ` and ` SENDBACK ` with your own data, unlike before due to formatting you only need base64 encoding to be url safe for the sendback url if you provide it. `` hey.cafe/request/permission/TYPE/KEY/SENDBACK `` KEY: This is the key we sent back to you when you did the first auth request for sign in. TYPE: This is the type of data you want, at this time we have ` location ` and ` email `, or for both ` all ` as the options. SENDBACK: is a url to send the user to when done, we do append ` ?key=KEY ` with the key again to your URL when sending them back, we also send ` &permission=TYPE ` back so you know what was just requested. ** How to get data ** You can get the data in the normal ` account_key ` check as a new variable will appear depending on the data requested. If the variables are not present in response_data you know the permissions where not granted or you did not ask for it yet. Email: Will result in a new variable with the name email. Location: Will have 2 variables one for country and one that is state. The data may have the value false if the user never set the location on Hey.café. ----