РАЗРАБОТКА МОБИЛЬНЫХ ПРИЛОЖЕНИЙ НА …Ссылки OAuth

Preview:

Citation preview

РАЗРАБОТКА МОБИЛЬНЫХ ПРИЛОЖЕНИЙ НА БАЗЕ ПЛАТФОРМЫ

ПреподавательПапулин Сергей Юрьевич (papulin_hse@mail.ru)

Москва, 2017

Факультатив ФКН

АссистентЦырлин Никита (nstsyrlin@gmail.com)

OAuth 2.0

Основные темы

Аутентификация через Google Firebase

Подключение к сервисам Google через OAuth

Oauth 2.0

Oauth 2.0

https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code

Подключение к сервисам Google через OAuth

https://console.developers.google.com/

Активируйте необходимые API (диск, почта и пр.)

Создайте учетные данные авторизации для приложения

Определите охват доступа

https://developers.google.com/identity/protocols/OAuth2

Консоль разработчика

https://developers.google.com/identity/protocols/OAuth2UserAgent

Приложение GoogleOAuthMApp

OAuth API

Привилегии

http://tizen.org/privilege/internet

<access origin="*" subdomains="true"/>

Приложение GoogleOAuthMApp

id="main"

Click

Новое окно Авторизация

Разрешить

Token

Приложение GoogleOAuthMApp

id="main"

Click

Новое окно

Авторизация

Разрешить

Token

адрес1 адрес2

Token

адрес3&approve

Отслеживает адрескаждые 0.1 сек

Получение API

<body><div id="main" class="page">

<div class="contents"><button onclick="mobileInit();">click</button>

</div></div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script><script src="https://apis.google.com/js/api.js" type="text/javascript"></script><script type="text/javascript">

gapi.load('client:auth2:signin2', init1);</script>

</body>

var url = "https://accounts.google.com/o/oauth2/v2/auth";var client_id = “YOUR_CLIENT_ID";var redirect_uri = "urn:ietf:wg:oauth:2.0:oob";var response_type = "code";var scope = "profile";

var full_url = url + "?" + 'client_id=' + encodeURIComponent(client_id) + '&redirect_uri=' + encodeURIComponent(redirect_uri) + '&response_type=' + encodeURIComponent(response_type) + '&scope=' + encodeURIComponent(scope);

var win = window.open(full_url);var code = null;

var codeRequest = window.setInterval(function() { if (win.document.URL.indexOf("approval") != -1) {

clearInterval(codeRequest);code = $(win.document).find("#code").val()win.close();

}}, 100);

Получение token

token

Аутентификация через Google Firebase

https://console.firebase.google.comКонсоль Firebase

Приложение OAuthMApp

Firebase API

Привилегии

http://tizen.org/privilege/internet

<access origin="*" subdomains="true"/>

Подключение Firebase API к приложению

<script src="https://www.gstatic.com/firebasejs/3.7.0/firebase.js"></script><script src="https://www.gstatic.com/firebasejs/3.6.10/firebase-auth.js"></script><script src="https://cdn.firebase.com/libs/firebaseui/1.0.0/firebaseui.js"></script><link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/1.0.0/firebaseui.css" /><script>

// Initialize Firebasevar config = {

apiKey: “YOUR_API_KEY",authDomain: “YOUR_AUTH_DOMAIN",

};

firebase.initializeApp(config);</script>

Аутентификация через Firebase

var uiConfig = {callbacks: {

signInSuccess: function(currentUser, credential, redirectUrl) {…

},signInSuccessUrl: 'main.html',signInOptions: [

// Leave the lines as is for the providers you want to offer your users.firebase.auth.GoogleAuthProvider.PROVIDER_ID,firebase.auth.FacebookAuthProvider.PROVIDER_ID,firebase.auth.TwitterAuthProvider.PROVIDER_ID,firebase.auth.GithubAuthProvider.PROVIDER_ID,firebase.auth.EmailAuthProvider.PROVIDER_ID

],tosUrl: '<your-tos-url>'

};

Для web-приложений доступа опция аутентификации по электронной почте

Ссылки

OAuthhttps://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-codehttp://docs.apigee.com/api-services/content/oauth-introductionhttps://developer.tizen.org/development/api-tutorials/native-application/account/oauth-2.0

CORShttps://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORShttps://developer.tizen.org/development/guides/web-application/w3chtml5supplementary-features/security/cross-origin-resource-sharing-0

https://firebase.google.com/docs/https://github.com/firebase/firebaseui-webhttps://firebase.google.com/docs/auth/web/manage-usershttps://firebase.google.com/docs/cli/

Recommended