This package provides possibility for third party applications to log in with trivago.
Important notes:
This library uses native es6 Promise. If you need support IE9+ please define a polyfill in your application.
This library works only in browser environments.
First of all you need to get a client ID.
If you don't have one, please send a request to Christina.Gkofa@trivago.com
Include trv.sdk.js
as a script in your application or use it as a dependency in your code.
As a result you should have trvOauthSdk
function available in your code.
Next call the initializer function trvOauthSdk
to register your clientId.
This returns an object with authorize method in it.
Additionally you can pass an options object in order set up scopes. See API reference for more details.
const sdk = trvOauthSdk('your-client-id');
sdk.authorize();
const init = require('trv-oauth-sdk');
const sdk = init('your-client-id');
sdk.authorize();
We have several predefined scopes that you can use at the moment:
If you don't pass any scopes, default one will be used (personal_info).
Method to initialize your application. Returns an object with authorize
method in it.
Throws an error if clientId
was not specified or was not a string.
<string>
required
A clientId provided by trivago in order to make possible to log in with trivago.
<object>
optional
string
:Oauth scope, default: '' (empty string)
Method that can be triggered on some action (click on a button) in order to open a popup and enter trivago credentials.
Consider the next example which shows how this library can be used:
<script type="text/javascript" src="path/to/trv.sdk.js"></script>
<script type="text/javascript">
var sdk = trvOauthSdk('your-client-id');
var button = document.getElementById('button');
button.addEventListener('click', onClick);
function onClick() {
sdk.authorize().then(function(data) {
console.log('Well done!', data);
}).catch(function(err) {
console.log('Something went wrong', err);
});
}
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。