# Http\_code 301 redirect\_url issue localhost authorize

**URL:** <https://community.hubspot.com/t/http-code-301-redirect-url-issue-localhost-authorize/11332>\
**Category:** APIs & Integrations\
**Tags:** oauth\
**Created:** [October 11, 2018, 7:46am UTC](https://community.hubspot.com/t/http-code-301-redirect-url-issue-localhost-authorize/11332 "2018-10-11T07:46:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 11, 2018, 7:46am UTC](https://community.hubspot.com/t/http-code-301-redirect-url-issue-localhost-authorize/11332/1 "2018-10-11T07:46:13Z")

</div>

i have issue hunspot with redirection return 301 code

$ApiDataSet = array(  
‘client\_id’ =\> ‘XXXXXX’,  
‘scope’ =\> ‘contacts’,  
‘redirect\_uri’ =\> ‘[http://localhost/mytask/account.php](http://localhost/mytask/account.php)’  
);

$header = array(  
‘Accept: application/json’,  
‘Content-Type: application/x-www-form-urlencoded;charset=utf-8’,  
);

$endpoint = ‘[http://app.hubspot.com/oauth/authorize](http://app.hubspot.com/oauth/authorize)’;  
$ch = curl\_init();  
curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);  
curl\_setopt($ch, CURLOPT\_POSTFIELDS, $ApiDataSet);  
@curl\_setopt($ch, CURLOPT\_URL, $endpoint);  
@curl\_setopt($ch, CURLOPT\_HTTPHEADER, $header);  
@curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);  
curl\_setopt($ch, CURLOPT\_UNRESTRICTED\_AUTH, true);  
$response = curl\_exec($ch);  
$info = curl\_getinfo($ch);  
curl\_close($ch);  
print\_r($info);

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 11, 2018, 3:02pm UTC](https://community.hubspot.com/t/http-code-301-redirect-url-issue-localhost-authorize/11332/2 "2018-10-11T15:02:51Z")

</div>

Hi [@Ankit](https://community.hubspot.com/u/ankit),

What error are you receiving?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 12, 2018, 6:43am UTC](https://community.hubspot.com/t/http-code-301-redirect-url-issue-localhost-authorize/11332/3 "2018-10-12T06:43:55Z")

</div>

some redirection issues, to same page redirect call.  
so i solved Thanks Isaac\_Takushi for the interest.

This is the my final code for this

$client\_id = ‘xxx-xxx-xxxx’;

$client\_secret = ‘xxx-xxx-xxx’;

$protocol = (!empty($\_SERVER[‘HTTPS’]) && $\_SERVER[‘HTTPS’] !== ‘off’ || $\_SERVER[‘SERVER\_PORT’] == 443) ? ‘https://’ : ‘http://’;

$redirect\_uri = $protocol.$\_SERVER[‘HTTP\_HOST’].‘/’.$\_SERVER[‘PHP\_SELF’];

$url\_auth = ‘[http://app.hubspot.com/oauth/authorize?client\_id=‘.$client\_id.’&scope=contacts%20automation&redirect\_uri=](http://app.hubspot.com/oauth/authorize?client_id='.%24client_id.'&scope=contacts%20automation&redirect_uri=)’.$redirect\_uri;

Login

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 12, 2018, 11:55am UTC](https://community.hubspot.com/t/http-code-301-redirect-url-issue-localhost-authorize/11332/4 "2018-10-12T11:55:39Z")

</div>

I’m glad you sorted it out, [@Ankit](https://community.hubspot.com/u/ankit)!
