void BtnAuthYouTube_TouchUpInside(object sender, EventArgs e) { switchToAuth("YouTube", YouTubeHook.GetLoginURL( clientId: Constants.YouTubeAPIKey, redirect: Constants.YouTubeRedirectURL)); }
protected override void OnStart() { base.OnStart(); NotificationHandler.CancelNotification(this); YouTubeHook.VerboseCallback = (o) => Console.WriteLine(o); Settings.LoadInfos(); var code = string.Empty; try { var urlparams = Uptred.Core.QueryParametersFromUrl(Intent.Data.ToString()); code = urlparams["code"]; } catch (Exception e) { Console.WriteLine(e.Message); Settings.YouTubeHook = null; } if (code != string.Empty) { try { Settings.YouTubeHook = YouTubeHook.Authorize( authCode: code, clientId: ApiKeys.YouTubeClientId, secret: ApiKeys.YouTubeClientSecret, redirect: ApiKeys.YouTubeRedirectURL); Console.WriteLine("Logged in as " + Settings.YouTubeHook.DisplayName); Settings.YouTubeRefreshToken = Settings.YouTubeHook.RefreshToken; } catch (Exception e) { Console.WriteLine(e.Message); Settings.YouTubeHook = null; } } else { try { Settings.YouTubeHook = YouTubeHook.ReAuthorize( refreshToken: Settings.YouTubeRefreshToken, clientId: ApiKeys.YouTubeClientId, secret: ApiKeys.YouTubeClientSecret, redirect: ApiKeys.YouTubeRedirectURL); Console.WriteLine("Logged in as " + Settings.YouTubeHook.DisplayName); } catch (Exception e) { Console.WriteLine(e.Message); Settings.YouTubeHook = null; } } if (Settings.YouTubeHook == null) { StartActivity(new Intent(Intent.ActionView, Uri.Parse( YouTubeHook.GetLoginURL(clientId: ApiKeys.YouTubeClientId, redirect: ApiKeys.YouTubeRedirectURL)))); } else { FindViewById <TextView>(Resource.Id.lblVerifier).Text = Settings.YouTubeHook.DisplayName; } }