mirror of https://github.com/Squidex/squidex.git
18 changed files with 182 additions and 168 deletions
@ -1,16 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Reflection; |
|
||||
|
|
||||
namespace Squidex.Extensions |
|
||||
{ |
|
||||
public static class SquidexExtensions |
|
||||
{ |
|
||||
public static readonly Assembly Assembly = typeof(SquidexExtensions).Assembly; |
|
||||
} |
|
||||
} |
|
||||
@ -1,69 +0,0 @@ |
|||||
// ==========================================================================
|
|
||||
// Squidex Headless CMS
|
|
||||
// ==========================================================================
|
|
||||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|
||||
// All rights reserved. Licensed under the MIT license.
|
|
||||
// ==========================================================================
|
|
||||
|
|
||||
using System.Threading.Tasks; |
|
||||
using CoreTweet; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using Squidex.Extensions.Actions.Twitter; |
|
||||
|
|
||||
namespace Squidex.Areas.Api.Controllers.Rules |
|
||||
{ |
|
||||
public sealed class TwitterController : Controller |
|
||||
{ |
|
||||
private readonly TwitterOptions twitterOptions; |
|
||||
|
|
||||
public TwitterController(IOptions<TwitterOptions> twitterOptions) |
|
||||
{ |
|
||||
this.twitterOptions = twitterOptions.Value; |
|
||||
} |
|
||||
|
|
||||
public sealed class TokenRequest |
|
||||
{ |
|
||||
public string PinCode { get; set; } |
|
||||
|
|
||||
public string RequestToken { get; set; } |
|
||||
|
|
||||
public string RequestTokenSecret { get; set; } |
|
||||
} |
|
||||
|
|
||||
[HttpGet] |
|
||||
[Route("rules/twitter/auth")] |
|
||||
public async Task<IActionResult> Auth() |
|
||||
{ |
|
||||
var session = await OAuth.AuthorizeAsync(twitterOptions.ClientId, twitterOptions.ClientSecret); |
|
||||
|
|
||||
return Ok(new |
|
||||
{ |
|
||||
session.AuthorizeUri, |
|
||||
session.RequestToken, |
|
||||
session.RequestTokenSecret |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
[HttpPost] |
|
||||
[Route("rules/twitter/token")] |
|
||||
public async Task<IActionResult> AuthComplete([FromBody] TokenRequest request) |
|
||||
{ |
|
||||
var session = new OAuth.OAuthSession |
|
||||
{ |
|
||||
ConsumerKey = twitterOptions.ClientId, |
|
||||
ConsumerSecret = twitterOptions.ClientSecret, |
|
||||
RequestToken = request.RequestToken, |
|
||||
RequestTokenSecret = request.RequestTokenSecret |
|
||||
}; |
|
||||
|
|
||||
var tokens = await session.GetTokensAsync(request.PinCode); |
|
||||
|
|
||||
return Ok(new |
|
||||
{ |
|
||||
tokens.AccessToken, |
|
||||
tokens.AccessTokenSecret |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue