dcsimg
Page 2 of 2 FirstFirst 12
Results 41 to 50 of 50

Thread: Make a webrequest in asana

  1. #41

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    I hope this is wrapped up in 11 days and I hope you have a great holiday! After working with me again, you will need it. Are you going any place special?

    OK, so I just had a major breakthrough and I am so, so happy.
    I have a little test app in VB.NET. The reason it is in that language, even though I am developing in C#, is because code I found on stackoverflow that I was able to get to work is in VB.NET so I am continuing working with that.

    I am using OAuth. In Asana, after I registered this VB.NET application, I got a string generated on the asana registration page.
    https://app.asana.com/-/oauth_authorize?response_type=code&client_id=<Client ID>&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&state=<STATE_PARAM>
    Except I substituted state=MMOCK in the STATE_PARAM param and my application's particular client id.

    When I was executing this via HttpWebRequest and HttpWebResponse calls (I can post if you need to see it), I didn't understand why I was getting back html. I saved it to a file and opened the file and it was the asana login page. I didn't know what i was supposed to do with that.
    Code:
            ' This is returning me html which, if I save it to a file and open it, is the login to asana
            Dim response As String = GetResponse(uri)
    Then it occurred to me what I need to do was this:
    Code:
           
            Dim process As System.Diagnostics.Process = New System.Diagnostics.Process()
            process.StartInfo.FileName = uri
            process.StartInfo.Verb = "open"
            process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
    
            Try
                process.Start()
            Catch
            End Try
    Because when I did that, it launched an internet browser window, not with the asana login but more specifically a page that said Grant Permission to VB.NET Asana Interface! (Probably because I am already logged into asana on my machine)
    When I clicked Allow, it navigated to a very simple web page saying:
    Please copy this code, switch to your application, and paste it there: 0/<a beautiful hexadecimal code>

    So I think I am ready for the next step which for now is to manually copy that code into my VB.NET code (which I have stopped on a break point) and continuing the authorization. That is, getting the token I need to continue as "me".
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #42

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    Nice! All that is working. When I issued this request: https://app.asana.com/api/1.0/users/me, it returned information about me as an asana user.
    Then I called my friend from HR over and I logged out of asana on my machine and we ran my little test app. Since no one was logged in, asana prompted. Dawn entered her asana credentials. When my coded ran the request https://app.asana.com/api/1.0/users/me, it gave us info about her.

    So very happy at this point!

    The two remaining questions I have are:
    1) What actually happens when one hour is up and the token expires? I know my code can issue a call to refresh and get a new token, all behind the scenes of the user knowing. I guess I can test this out by letting my token expire. I assume I'll get a response saying so, and that would mean time to refresh.
    2) Could I possibly screen-scrape the initial token from asana when the user issues https://app.asana.com/-/oauth_authorize... so he doesn't have to manually "copy this code, switch to your application, and paste it there" which is what the little web page says to do?

    I am looking into these answers now...
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  3. #43

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    While you were sleeping...I came up with some questions. But overall, it is working awesomely!

    I don't know if I can screen-scrape... Can I? Should I?

    I am using OAuth and as you know, there are a lot of applications out there that we use everyday and we've probably been using OAuth as we run them. Is it the norm that you only have to allow access once? Dawn said she's used pinterest, it asked her if she wanted to let it access her facebook account, she said yes, and that was that. I didn't know if I could save the person's last token they used and find out it's expired but just issue the refresh call against it.

    These are minor fix-ups so I wanted to thank you again for all your help!
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #44

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    I don't see anything here that leads me to believe that I can bypass or hide any of the login/authentication steps. Do you agree? https://asana.com/developers/documen...g-started/auth
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  5. #45
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,465

    Re: Make a webrequest in asana

    Hi,

    sorry i had a project deadline on Friday and so was too busy to visit the forums, sounds like your have made a lot of progress on your own though which i great

    I am going to the south of France first for 2 weeks and then i am back for a week and then go to Italy for 8 days so very much looking forward to the holiday season this year.

    I have very briefly read your posts but i have a lot on this weekend, i will reply properly tomorrow !
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  6. #46

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    I *have* made a lot of progress! If you want, hold off on anything else until I post back on Monday. (It's Sunday now and I am eating lunch and getting ready to go to the theater).

    What part of Italy? My daughter is going to Italy the end of August, for three months, to study abroad (we are in the USA). She is an art major in college. (The show we are going to see is because he helped paint the set ).
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  7. #47
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,465

    Re: Make a webrequest in asana

    I am going to Venice and Verona, i have never been there before so i am looking forward to it.

    Italy is a great place to go for an Art student i am sure she will have a ball

    anyway back to your questions

    1) What actually happens when one hour is up and the token expires?
    The token will expire and you wont be able to make calls using it, then you would need to get a new token which i think you pretty much figured out anyway

    2) Could I possibly screen-scrape the initial token from asana
    no i dont think that the way, what i think your missing is the redirect URI so in the documentation it has this -

    https://app.asana.com/-/oauth_authorize?
    client_id=123&
    redirect_uri=https://myapp.com/oauth&
    response_type=token&
    state=somerandomstate

    so if your site was a website it would be easy, you would give it a real page inside your app which would process the data returned (it passes them back via Querystrings)

    As yours is a desktop system you have a urn, which i assume works in a similar way ( the page auto redirects to it once the user has hit the login button.)

    I will need to a bit more reading though i think to see how the urn stuff works
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  8. #48

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    Yeah, scratch the screen scraping! I only wanted to do that to prevent the user from *constantly* having to copy and paste their token from asana to my app, but now I realize they will do that once and from then on I will use the token I save to the database (user-specific) and if it's expired, I can do the refresh behind the scenes. So really no need for that anymore!

    So I believe I can rest my case, no further questions! I will post back that the refresh worked later today. I am on something else while waiting for the hour that my current token is good for then I wanted to see the response I get when it's expired and do the exchange for a new token.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  9. #49
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,465

    Re: Make a webrequest in asana

    So did the refresh work, are you happy its all working now?
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  10. #50

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Sitting in an empty room trying to forget the past
    Posts
    4,046

    Re: Make a webrequest in asana

    I am happy! Just feeling bad that I forgot to post back! I will come back once more, to summarize the process for the next person...
    Enjoy your holiday!!! And thank you again for helping me. I will buy you dinner if you ever make it across the pond .
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width