[GH-ISSUE #76] Custom oauth2 access #48

Closed
opened 2026-03-03 16:45:10 +03:00 by kerem · 1 comment
Owner

Originally created by @ctippur on GitHub (Jun 9, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/76

Hello,
I am trying a custom oauth2 access and I am new to swift.

I am following instruction from https://django-oauth-toolkit.readthedocs.org/en/0.3.2/tutorial/rest_framework_integration.html.

The authorization process is
Use initial username and password to get a token
Use the token to perform further api calls.

In my case, there is only accessTokenUrl and authorizeUrl is not applicable. Wondering how to proceed further.
Appreciate any inputs.

  • S

    func doOAuthScreener(){

      let oauthswift = OAuth2Swift(
    
          //https://django-oauth-toolkit.readthedocs.org/en/latest/rest-framework/getting_started.html
    
          consumerKey:    Screener["consumerKey"]!,
    
          consumerSecret: Screener["consumerSecret"]!,
    
          authorizeUrl:   HERE, 
    
          accessTokenUrl: HERE, // This seem to be http://localhost:8000/o/token/
    
          responseType:   "code"
    
      )
    
    
    
    
    
      let state: String = generateStateWithLength(20) as String
    
    
    
    
    
      oauthswift.authorizeWithCallbackURL( NSURL(string: "HERE")!, scope: "user,repo", state: state, success: {
    
          credential, response, parameters in
    
          self.showAlertView("Screener", message: "oauth_token:\(credential.oauth_token)")
    
          }, failure: {(error:NSError!) -> Void in
    
              println(error.localizedDescription)
    
      })    
    

    }

Originally created by @ctippur on GitHub (Jun 9, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/76 Hello, I am trying a custom oauth2 access and I am new to swift. I am following instruction from https://django-oauth-toolkit.readthedocs.org/en/0.3.2/tutorial/rest_framework_integration.html. The authorization process is Use initial username and password to get a token Use the token to perform further api calls. In my case, there is only accessTokenUrl and authorizeUrl is not applicable. Wondering how to proceed further. Appreciate any inputs. - S func doOAuthScreener(){ ``` let oauthswift = OAuth2Swift( //https://django-oauth-toolkit.readthedocs.org/en/latest/rest-framework/getting_started.html consumerKey: Screener["consumerKey"]!, consumerSecret: Screener["consumerSecret"]!, authorizeUrl: HERE, accessTokenUrl: HERE, // This seem to be http://localhost:8000/o/token/ responseType: "code" ) let state: String = generateStateWithLength(20) as String oauthswift.authorizeWithCallbackURL( NSURL(string: "HERE")!, scope: "user,repo", state: state, success: { credential, response, parameters in self.showAlertView("Screener", message: "oauth_token:\(credential.oauth_token)") }, failure: {(error:NSError!) -> Void in println(error.localizedDescription) }) ``` }
kerem 2026-03-03 16:45:10 +03:00
Author
Owner

@phimage commented on GitHub (Nov 9, 2015):

django not follow the protocol
So you can use any network framework or Foundation classes like NSMutableRequest to make a request

method = POST 
url = http://<client_id>:<client_secret>@localhostoryoururl:8000/o/token/
query param = “grant_type=password&username=<user_name>&password=<password>” 

I have no idea how to do this with OauthSwift
you can just set the token after retrieved it into OAuthSwift objects

<!-- gh-comment-id:155025922 --> @phimage commented on GitHub (Nov 9, 2015): django not follow the protocol So you can use any network framework or Foundation classes like NSMutableRequest to make a request ``` method = POST url = http://<client_id>:<client_secret>@localhostoryoururl:8000/o/token/ query param = “grant_type=password&username=<user_name>&password=<password>” ``` I have no idea how to do this with OauthSwift you can just set the token after retrieved it into OAuthSwift objects
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#48
No description provided.