Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Oauth.php
Go to the documentation of this file.
1 <?php
7 
8 class Oauth
9 {
14  const LENGTH_TOKEN = 32;
15 
16  const LENGTH_TOKEN_SECRET = 32;
17 
19 
26  const LENGTH_CONSUMER_KEY = 32;
27 
29 
35  const LENGTH_NONCE = 32;
36 
42  const CALLBACK_ESTABLISHED = 'oob';
43 
47  protected $_mathRandom;
48 
52  public function __construct(\Magento\Framework\Math\Random $mathRandom)
53  {
54  $this->_mathRandom = $mathRandom;
55  }
56 
63  public function generateRandomString($length)
64  {
65  return $this->_mathRandom->getRandomString(
66  $length,
67  \Magento\Framework\Math\Random::CHARS_DIGITS . \Magento\Framework\Math\Random::CHARS_LOWERS
68  );
69  }
70 
76  public function generateToken()
77  {
78  return $this->generateRandomString(self::LENGTH_TOKEN);
79  }
80 
86  public function generateTokenSecret()
87  {
88  return $this->generateRandomString(self::LENGTH_TOKEN_SECRET);
89  }
90 
96  public function generateVerifier()
97  {
98  return $this->generateRandomString(self::LENGTH_TOKEN_VERIFIER);
99  }
100 
106  public function generateConsumerKey()
107  {
108  return $this->generateRandomString(self::LENGTH_CONSUMER_KEY);
109  }
110 
116  public function generateConsumerSecret()
117  {
118  return $this->generateRandomString(self::LENGTH_CONSUMER_SECRET);
119  }
120 }
__construct(\Magento\Framework\Math\Random $mathRandom)
Definition: Oauth.php:52