Git Product home page Git Product logo

Comments (4)

oliverfoggin avatar oliverfoggin commented on August 15, 2024

Hmm... you shouldn't really have to get the access token at all. What are you wanting to do with it?

from oauth2client.

stoneros avatar stoneros commented on August 15, 2024

will, the server I try to connect has a document said i need the token to get content from service . like this...https://api.weibo.com/2/statuses/public_timeline.json?access_token=abcd

from oauth2client.

oliverfoggin avatar oliverfoggin commented on August 15, 2024

Ah, you can make the request through the NXOAuth2 library and it will incorporate the access token into the request for you.

You can either do...

[NXOAuth2Request performMethod:@"GET"
onResource:[NSURL urlWithString:@"https://api.weibo.com/2/statuses/public_timeline.json"]
usingParameters:nil
withAccount: //your account
sendProgressHandler:nil
responseHandler:
^(NSURLResponse *response, NSData *responseData, NSError *error) {
//deal with the request here.
}];

This works asynchronously so does everything in one line of code. By putting the account info in there it adds all the access token stuff for you.

Or you can get a regular NSURLRequest by doing...

NXOAuth2Request *authRequest = [[NXOAuth2Request alloc] initWith ... some stuff that I can't remember off the top of my head];
authRequest.account = your account;
NSURLRequest *signedRequest = [authRequest signedRequest];

Then you can use this signedRequest as normal and it has all the auth stuff in it already.

HTH

Thanks

from oauth2client.

stoneros avatar stoneros commented on August 15, 2024

Thanks this really picked me up:)

btw:
I set my redirect uri to MyApp: //
and when I use
[[NXOAuth2AccountStore sharedStore] requestAccessToAccountWithType:@"myFancyService"
withPreparedAuthorizationURLHandler:^(NSURL *preparedURL){
[[NSWorkspace sharedWorkspace] openURL:preparedURL];
}];
it's redirect to the url with the code like:"myapp://connect?code=e72c62b906c62de31d5fefa377bb092a" , what should I do with it?

from oauth2client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.