Mautic Community Forums

oAuth 1a

Hi. I want to work with Mautic use oAuth1 authorization, but I is not working. Here is the sequence of my actions.

Customizable data needed for authentication.

Code:
$settings = [ 'baseUrl' => 'http://crm.mymarketingmachine.co.uk', 'version' => 'OAuth1a', 'clientKey' => '59dvw9fp8gogkskok0sdwwks8k4088w4sco4ks00440skg0qwer', 'clientSecret' => '54y6z0zztqkookockgogo0kwwws048c8k44kggo4kgsgkcwqqq', ]; if ($auth->validateAccessToken()) {
        if ($auth->accessTokenUpdated()) {
            $arr = $auth->getAccessTokenData();

        }

    }</div>
I was redirected to mautic and offers to download the file with my token.
I downloaded and writes them into an array.
Code:
$settings = [ 'baseUrl' => 'http://crm.mymarketingmachine.co.uk', 'version' => 'OAuth1a', 'clientKey' => '59dvw9fp8gogkskok0sdwwks8k4088w4sco4ks00440skg0qwer', 'clientSecret' =>'54y6z0zztqkookockgogo0kwwws048c8k44kggo4kgsgkcwqqq', 'accessToken' => '3xu9kcrlkrqqgw8ocock0k0k0gkksggs04ksw40wo4oggcoosk', 'accessTokenSecret' => '2hprfmn4jcis0c08kcw4wkc4woks4gkfd8cs0kw4oc4ggo8gws' ];
I try to get the data in response to get the error.
Code:
[error] => Array ( [message] => token_rejected ['code'] => 0 )
What am i doing wrong?

Hi. I want to work with Mautic use oAuth1 authorization, but I is not working. Here is the sequence of my actions.
Customizable data needed for authentication.

[code]$settings = [
‘baseUrl’ => ‘http://crm.mymarketingmachine.co.uk’,
‘version’ => ‘OAuth1a’,
‘clientKey’ => ‘59dvw9fp8gogkskok0sdwwks8k4088w4sco4ks00440skg0qwer’,
‘clientSecret’ => ‘54y6z0zztqkookockgogo0kwwws048c8k44kggo4kgsgkcwqqq’,
];
if ($auth->validateAccessToken()) {

        if ($auth->accessTokenUpdated()) {
            $arr = $auth->getAccessTokenData();

        }

    }[/code]

I was redirected to mautic and offers to download the file with my token.
I downloaded and writes them into an array.

$settings = [ 'baseUrl' => 'http://crm.mymarketingmachine.co.uk', 'version' => 'OAuth1a', 'clientKey' => '59dvw9fp8gogkskok0sdwwks8k4088w4sco4ks00440skg0qwer', 'clientSecret' =>'54y6z0zztqkookockgogo0kwwws048c8k44kggo4kgsgkcwqqq', 'accessToken' => '3xu9kcrlkrqqgw8ocock0k0k0gkksggs04ksw40wo4oggcoosk', 'accessTokenSecret' => '2hprfmn4jcis0c08kcw4wkc4woks4gkfd8cs0kw4oc4ggo8gws' ];
I try to get the data in response to get the error.

[error] => Array
        (
            [message] => token_rejected
            ['code'] => 0
        )

What am i doing wrong?

I’d suggest to generate new API credentials and delete those you mentioned in your post because someone could now use API to modify your data.

I don’t see any problem in your code. I just used API Tester to connect to Mautic via oAuth1a and it worked just fine. Maybe also try if you could log in via API Tester. That would tell you if the problem is in Mautic or in your code.

One more note; you should save the tokens stored in $arr = $auth->getAccessTokenData();

Im getting the same issue here. token_rejected. Generated tokens (finally because API tester didn’t work and left me with a blank response each time).

Now that I have the tokens, they don’t work. I am begging for this to work. Please.

Make sure you use the right Oauth version tokens to the right Oauth authentication. Also check the logs for some error messages when you get a blank response.