Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    May 20, 2015 @ 10:20
    Ismail Mayat
    0

    Google oauth token

    Anders,

    We have a live console app running, it uses skybrud social libs. I created the auth stuff in umbraco then wrote a method to get me back that actual json with the token in it. I created json files one for each of the services i am using and pasted json in there for each service.  My app reads those files and deserialses to oauth object these are passed to skybrud services to get data.

    This up until 2 days ago was all working fine.  However now the google calls keep returning invalid account.  I went into google services revoked the app then re added and updated my json file with token it seems to be working again.  I will know for sure around 1pm today as it runs as a scheduled azure webjob.  

    My question is I guess google tokens have expiry date?  It looks like in your code social for Umbraco if token expires you pass access token and creates new one? So I would I guess need to do something similar or in my app make webapi call to webapi method I already have that uses Umbraco social so it will work even if token expires as your code creates new one.

    Regards

    Ismail

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    May 20, 2015 @ 12:35
    Anders Bjerner
    1

    Hi Ismail,

    When you authenticate with Google, you specify an access type, which can be either online or offline.

    With online you get an access token that will only live for an hour or so. offline will give you an access token as with online, but also a refresh token, which is used to obtain new access tokens without the user having to login again.

    The refresh token doesn't have an expiry date, but I think it will be deauthorized if the user changes his password. There may also be other factors that will deauthorize the refresh token, but it shouldn't expire after a certain amount of time.

    Since you're writing that it worked until two days ago, I'm assuming you have used a refresh token, and then something around the user probably has changed (eg. changed password).

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    May 20, 2015 @ 13:09
    Ismail Mayat
    0

    Anders,

    Password has not been changed as I logged in yesterday to fix up by revoking access and re adding. When you authenticate part of the scope is offline access so not that.  Anyhow I will keep an eye on it and see what happens. By the way you going to be at codegarden? I need to give you big high 5 when i see you :-}

    Regards

    Ismail

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    May 20, 2015 @ 15:30
    Anders Bjerner
    1

    Hi again,

    Although its still under development, you can have a peek at the new site for Skybrud.Social for a bit more information on authentication http://skybrudsocial.azurewebsites.net/google/authentication/

    The page also has some links to Google's own documentation - in particular you can read more about token expiration. It has some information I don't remember seeing before.

    And yes, I'm going to Codegarden :D

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    May 20, 2015 @ 16:14
    Ismail Mayat
    0

    Anders,

    The app ran fine this lunch time and it got youtube stats.  Will keep an eye on it.  Awesome regarding the docs will have a read.  Will catch up with you at cg owe you high 5 and a coffee ;-}

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 18, 2015 @ 13:51
    Ismail Mayat
    0

    Anders,

    The youtube stuff has stopped working again last successful run was on 11 June. I found https://developers.google.com/google-apps/sites/faq_gdata that says

    Does a ClientLogin authentication token have an expiration date? A ClientLogin token can last for 2 weeks from the issue date, but this limit is service-specific and can be shorter.

    Any ideas?

    Regards

    Ismail

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Jun 18, 2015 @ 17:29
    Anders Bjerner
    0

    Hi Ismail,

    I think that page is a bit deprecated (they describe that responses are based on RSS and ATOM, while I'm pretty sure v3 of the various APIs use JSON). I haven't heard about ClientLogin authentication, so this may also because it is deprecated.

    Anyways, what kind of error do you get when trying to call the API? And can you post a bit about your code? From the information you have posted so far, I can't see why it shouldn't work.

    For stuff like this (scheduled tasks), we're storing a refresh token for the user, and then use that to make requests to the API. I think we have a few sites that have been running like this for more than a year without any problems, and without us having to re-authenticate, so I'm a bit clueless as to why your token will stop working.

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Jun 19, 2015 @ 09:00
    Ismail Mayat
    0

    Anders,

    For now I have updated my code so that I now get youtube stats via a webapi end point on my website. This has skybrud oauth setup and it seems to be working fine. I still do not understand why in the context of my console application it loses grant.

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft