# oauth2 authentication not working in iPhone

**URL:** <https://community.hubspot.com/t/oauth2-authentication-not-working-in-iphone/14978>\
**Category:** APIs & Integrations\
**Tags:** crm\
**Created:** [June 26, 2019, 9:21am UTC](https://community.hubspot.com/t/oauth2-authentication-not-working-in-iphone/14978 "2019-06-26T09:21:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manish6415](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/manish6415/32/62359_2.png) [@manish6415](https://community.hubspot.com/u/manish6415)\
**Post date:** [June 26, 2019, 9:21am UTC](https://community.hubspot.com/t/oauth2-authentication-not-working-in-iphone/14978/1 "2019-06-26T09:21:30Z")

</div>

Hello All,  
I am developing one iPhone app in which I need to implement login with hubspot.  
To implement this, I used oauth2 library in swift. In this I am using below code to do authorization.  
When I run the app, its navigating me to safari and asking to enter id and passwrod of Hubspot. When I enter it, its just keep me inside the website and showing 3 dots loading. Please check this screenshot for the same: [https://tinyurl.com/y3trpphr](https://tinyurl.com/y3trpphr)

func getAccess()  
{  
let oauthswift = OAuth2Swift(  
consumerKey: “\*\*\*\*”,  
consumerSecret: “\*\*\*\*”,  
authorizeUrl: “[https://app.hubspot.com/oauth/authorize](https://app.hubspot.com/oauth/authorize)”,  
accessTokenUrl: “[https://api.hubapi.com/oauth/v1/token](https://api.hubapi.com/oauth/v1/token)”,  
responseType : “code”  
)  
oauthswift.authorize(withCallbackURL: URL(string: “myapp://”), scope: “contacts”, state:“code”, success: { (credentials, response, parameters) in  
print(response as Any)  
}, failure: { (error) in  
print(error)  
})  
}

---

<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:** [July 1, 2019, 2:47pm UTC](https://community.hubspot.com/t/oauth2-authentication-not-working-in-iphone/14978/2 "2019-07-01T14:47:55Z")

</div>

Hi, @manish6415.

Apologies for the delayed response. I believe we missed this post last week because it posted on a different forum and moved here.

The behavior you describe sounds similar to [these reports](https://community.hubspot.com/t5/APIs-Integrations/Unable-to-complete-OAuth-with-scope-content-unless-account-has/m-p/277527). Can you ensure that your [authorization URL’s](https://developers.hubspot.com/docs/methods/oauth2/initiate-oauth-integration) `scope` and `redirect_uri` parameters are properly encoded?

---

<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:** [July 1, 2019, 3:04pm UTC](https://community.hubspot.com/t/oauth2-authentication-not-working-in-iphone/14978/3 "2019-07-01T15:04:58Z")

</div>

Also, to clarify, the OAuth process described [here](https://developers.hubspot.com/docs/methods/oauth2/oauth2-overview) is used to connect HubSpot developer [applications](https://developers.hubspot.com/docs/faq/how-do-i-create-an-app-in-hubspot) to production accounts.

This process is **not** a HubSpot login flow.

Users will only need to complete the flow _once_ unless they disconnect your app from their account. For more information on OAuth, check out [these FAQs](https://community.hubspot.com/t5/APIs-Integrations/HubSpot-OAuth-FAQ/m-p/262729#M23479).

If I’ve misunderstood your goal, please let me know.
