Пример #1
0
        private void LoginGithub(string accessToken)
        {
            Debug.Log("[LoginGithub] " + accessToken);

            var auth       = ModPlayerFB.Auth;
            var credential =
                GitHubAuthProvider.GetCredential(accessToken);

            auth.SignInWithCredentialAsync(credential).ContinueWith(task =>
            {
                if (task.IsCanceled)
                {
                    Debug.LogError("SignInWithCredentialAsync was canceled.");
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                    return;
                }

                var newUser = task.Result;
                Debug.LogFormat("User signed in successfully: {0} ({1})",
                                newUser.DisplayName, newUser.UserId);

                shouldClose = true;
            });
        }
 public void SignInWithGithub(string accessToken, Action <FirebaseUserResult> callback)
 {
     if ((Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) && !Application.isEditor)
     {
         Credential credential = GitHubAuthProvider.GetCredential(accessToken);
         targetBehaviour.StartCoroutine(ProcessFirebaseUserTaskRoutine(auth.SignInWithCredentialAsync(credential), callback));
     }
     else
     {
         WWWForm form = new WWWForm();
         form.AddField("access_token", accessToken);
         WWW www = new WWW(serviceUrl + "/signInWithGithub", form);
         targetBehaviour.StartCoroutine(ProcessWebServiceUserRoutine(www, callback));
     }
 }
        /// <summary>
        /// Attaches the given Github credentials to the user. This allows the user to sign in to this account in the future with credentials for such provider.
        /// </summary>
        /// <param name="token">The GitHub OAuth access token.</param>
        /// <returns>Task of IFirebaseAuthResult</returns>
        public IObservable <IFirebaseAuthResult> LinkWithGithub(string token)
        {
            AuthCredential credential = GitHubAuthProvider.GetCredential(token);

            return(LinkWithCredentialAsync(credential).ToObservable());
        }
        /// <summary>
        /// Attaches the given Github credentials to the user. This allows the user to sign in to this account in the future with credentials for such provider.
        /// </summary>
        /// <param name="token">The GitHub OAuth access token.</param>
        /// <returns>Task of IUserWrapper</returns>
        public async Task <IFirebaseAuthResult> LinkWithGithubAsync(string token)
        {
            AuthCredential credential = GitHubAuthProvider.GetCredential(token);

            return(await LinkWithCredentialAsync(credential));
        }
Пример #5
0
 public LoginController(GitHubAuthProvider gitHubAuthProvider)
 {
     _gitHubAuthProvider = gitHubAuthProvider;
 }
Пример #6
0
        /// <inheritdoc/>
        public IObservable <Unit> SignInWithGithub(string token)
        {
            AuthCredential credential = GitHubAuthProvider.GetCredential(token);

            return(SignInAsync(credential).ToObservable().Select(_ => Unit.Default));
        }
        public IAuthCredential GetCredential(string token)
        {
            var credential = GitHubAuthProvider.GetCredential(token);

            return(new AuthCredentialWrapper(credential));
        }