# url not found after authenticating

**URL:** <https://forum.mautic.org/t/url-not-found-after-authenticating/3457>\
**Category:** Development\
**Created:** [February 13, 2016, 8:08pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457 "2016-02-13T20:08:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jocenunes](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jocenunes](https://forum.mautic.org/u/jocenunes)\
**Post date:** [February 13, 2016, 8:08pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/1 "2016-02-13T20:08:27Z")

</div>

Hi,  
  
I have used Rest API OAuth 1a to create a new leads.  
  
[http://develop.fashionlearn.me/allprojectthorughajax](http://develop.fashionlearn.me/allprojectthorughajax)  
  
after authenticating the app,it redirecting to my following callback url ,  
  
  
  
[http://develop.fashionlearn.me/createleads?oauth\_token=bloq464byhsk4888s84c04o4cos804kkskc8c8o0ko0kggc0c&oauth\_verifier=1fex3sv652tc84kg804cok8g4s044scw80so0owwow0ggwo00](http://develop.fashionlearn.me/createleads?oauth_token=bloq464byhsk4888s84c04o4cos804kkskc8c8o0ko0kggc0c&oauth_verifier=1fex3sv652tc84kg804cok8g4s044scw80so0owwow0ggwo00)  
  
  
  
i have written the code here to create a new leads,but it showing me 404 from mautic on my page.  
  
  
  
  
  
$id=$\_GET[“oauth\_verifier”];  
  
$curl = curl\_init();  
  
$data = array(  
  
‘firstname’ =\> ‘Joce’,  
  
‘lastname’ =\> ‘Nuunes’,  
  
‘email’ =\> ‘jocenunes@fashionlearn.com.br’,  
  
‘ipAddress’ =\> $\_SERVER,  
  
‘owner’=\>$id  
  
  
  
);  
  
curl\_setopt\_array($curl, array(  
  
CURLOPT\_RETURNTRANSFER =\> 1,  
  
CURLOPT\_URL =\> ‘[http://162.243.61.31/leads/2899](http://162.243.61.31/leads/2899)’,  
  
CURLOPT\_USERAGENT =\> ‘Codular Sample cURL Request’,  
  
CURLOPT\_POST =\> 1,  
  
CURLOPT\_POSTFIELDS =\> $data  
  
));  
  
$resp = curl\_exec($curl);  
  
curl\_close($curl);

---

<div class="post-metadata">

**Author:** ![jocenunes](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jocenunes](https://forum.mautic.org/u/jocenunes)\
**Post date:** [February 13, 2016, 8:08pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/2 "2016-02-13T20:08:27Z")

</div>

Hi,  
I have used Rest API OAuth 1a to create a new leads.  
[http://develop.fashionlearn.me/allprojectthorughajax](http://develop.fashionlearn.me/allprojectthorughajax)  
after authenticating the app,it redirecting to my following callback url ,

[http://develop.fashionlearn.me/createleads?oauth\_token=bloq464byhsk4888s84c04o4cos804kkskc8c8o0ko0kggc0c&oauth\_verifier=1fex3sv652tc84kg804cok8g4s044scw80so0owwow0ggwo00](http://develop.fashionlearn.me/createleads?oauth_token=bloq464byhsk4888s84c04o4cos804kkskc8c8o0ko0kggc0c&oauth_verifier=1fex3sv652tc84kg804cok8g4s044scw80so0owwow0ggwo00)

i have written the code here to create a new leads,but it showing me 404 from mautic on my page.

```
$id=$_GET["oauth_verifier"];
		$curl = curl_init();
	$data = array(
'firstname' => 'Joce',
'lastname' => 'Nuunes',
'email' => 'jocenunes@fashionlearn.com.br',
'ipAddress' => $_SERVER['REMOTE_ADDR'],
'owner'=>$id

```

);  
curl\_setopt\_array($curl, array(  
CURLOPT\_RETURNTRANSFER =\> 1,  
CURLOPT\_URL =\> ‘[http://162.243.61.31/leads/2899](http://162.243.61.31/leads/2899)’,  
CURLOPT\_USERAGENT =\> ‘Codular Sample cURL Request’,  
CURLOPT\_POST =\> 1,  
CURLOPT\_POSTFIELDS =\> $data  
));  
$resp = curl\_exec($curl);  
curl\_close($curl);

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 15, 2016, 8:10pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/3 "2016-02-15T20:10:30Z")

</div>

I don’t see the OAuth access token used anywhere in your code. Please, use [https://github.com/mautic/api-library](https://github.com/mautic/api-library)

---

<div class="post-metadata">

**Author:** ![jocenunes](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jocenunes](https://forum.mautic.org/u/jocenunes)\
**Post date:** [February 15, 2016, 8:20pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/4 "2016-02-15T20:20:19Z")

</div>

I just modified the code,

```
public function createleadsAction(){
$id=$_GET["oauth_verifier"];

```

$outh=$this-\>view-\>session-\>storage-\>outh\_access\_token;  
$objmautic=Engine\_mautic\_lib\_MauticApi::getinstance();  
$outhnouns=rand(100000,999999);  
if($id){  
// urlencode(‘oauth\_callback’)=urlencode(“http%3A%2F%[2Fdevelop.fashionlearn.me](http://2Fdevelop.fashionlearn.me)%2Fallprojectthorughajax”)&urlencode(‘oauth\_consumer\_key’) = urlencode(“66aajqqqq9s04wk888ws0c4s0k8k0sc0soc0wkk88s04cg80s8”)&urlencode(‘oauth\_signature\_method’) = urlencode(“HMAC-SHA1”)&urlencode(‘oauth\_timestamp’) = urlencode(time()) &urlencode(‘oauth\_version’) = urlencode(‘1.0’)&urlencode(‘oauth\_nonce’)= urlencode(‘0678’));

```
$fields =array(
      'oauth_callback' => "https%3A%2F%2Fdevelop.fashionlearn.me%2Fcreateleads",
    'oauth_consumer_key' => "rgri60y4ipcos04848okosw8o4kwcwwckg8484kcokkg4k4s",
    'oauth_nonce'=>$outhnouns,
	'oauth_signature_method' => "HMAC-SHA1",
    'oauth_timestamp' => time(),
	'oauth_token'=>$outh,
    'oauth_version' => '1.0',
	'oauth_verifier'=>$id,
	 'firstname' => 'Jim',
'lastname' => 'Lead',
'email' => 'jim@his-site.com',
	'ipAddress' => $_SERVER['REMOTE_ADDR'],
	'lastActive'=>$date = date('m/d/Y h:i:s a', time()),
	'owner'=>''
	
	
);

```

$signature=$objmautic-\>signature(“POST”,“[http://marketing.fashionlearn.com.br/api/leads/new",$fields,"5zw2o0kkut8g8gs8os0k4wogs8044swk88oso4c44kwwwswc0s](http://marketing.fashionlearn.com.br/api/leads/new%22,%24fields,%225zw2o0kkut8g8gs8os0k4wogs8044swk88oso4c44kwwwswc0s)”);

```
//	$this->_helper->layout()->disableLayout();
	$curl = curl_init();

```

curl\_setopt\_array($curl, array(  
CURLOPT\_RETURNTRANSFER =\> 1,  
CURLOPT\_URL =\> ‘[http://marketing.fashionlearn.com.br/api/leads/new](http://marketing.fashionlearn.com.br/api/leads/new)’,  
CURLOPT\_USERAGENT =\> ‘Codular Sample cURL Request’,  
CURLOPT\_POST =\> 1,  
CURLOPT\_POSTFIELDS =\> array(  
‘oauth\_callback’ =\> “https%3A%2F%[2Fdevelop.fashionlearn.me](http://2Fdevelop.fashionlearn.me)%2Fcreateleads”,  
‘oauth\_consumer\_key’ =\> “rgri60y4ipcos04848okosw8o4kwcwwckg8484kcokkg4k4s”,  
‘oauth\_nonce’=\>$outhnouns,  
’ oauth\_signature’=\>$signature,  
‘oauth\_signature\_method’ =\> “HMAC-SHA1”,  
‘oauth\_timestamp’ =\> time(),  
‘oauth\_token’=\>$outh,  
‘oauth\_version’ =\> ‘1.0’,  
‘oauth\_verifier’=\>$id,  
‘firstname’ =\> ‘Jim’,  
‘lastname’ =\> ‘Lead’,  
‘email’ =\> ‘jim@his-site.com’,  
‘ipAddress’ =\> $\_SERVER[‘REMOTE\_ADDR’],  
‘lastActive’=\>$date = date(‘m/d/Y h:i:s a’, time()),  
‘owner’=\>’’

```
)

```

));  
$resp = curl\_exec($curl);  
curl\_close($curl);  
echo $resp; die;  
}  
else{  
echo “leads created”;die;  
}  
}

this is the callback function after authentication,  
i am getting 401 now  
{“error”:{“message”:“token\_rejected”,“code”:401}}

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 15, 2016, 8:30pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/5 "2016-02-15T20:30:11Z")

</div>

I’m sorry, I’ve never tried it with raw CURL calls like that.

---

<div class="post-metadata">

**Author:** ![jocenunes](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@jocenunes](https://forum.mautic.org/u/jocenunes)\
**Post date:** [February 16, 2016, 5:26pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/6 "2016-02-16T17:26:05Z")

</div>

That’s okay,  
But please check the values i am setting in header and with post data.  
I am retrieving the access token from session,so i don’t think it should say unauthorized access token 401.  
also can you please tell me how to deauthorize the app ?

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 17, 2016, 12:10pm UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/7 "2016-02-17T12:10:19Z")

</div>

I don’t have experience with the CURL code. I’m not sure how the token gets stored in the session. Maybe you should consider to use the Mautic API library to make your life easier. An app can be unauthorized if you remove the API credentials from Mautic.

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [February 15, 2016, 9:50am UTC](https://forum.mautic.org/t/url-not-found-after-authenticating/3457/8 "2016-02-15T09:50:07Z")

</div>

If I click on the link above, I see this:

`
Notice: Trying to get property of non-object in /var/www/develop.fashionlearn/application/modules/teach/controllers/TeachController.php on line 4877
{"error":{"message":"parameter_absent","code":400}}`
