Copied to clipboard

Flag this post as spam?

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


  • Tim 43 posts 197 karma points
    Mar 11, 2021 @ 13:03
    Tim
    0

    Invalid Scope Fields for Instagram

    Hi,

    I've installed Skybrud.Social on a V7 site, and I'm having trouble getting it to authenticate with Instagram.

    I've entered the details of the API (keys etc). I click authorize, and go through the login process, however I then get the following JSON displayed in the Popup:

    {"error_type": "OAuthException", "code": 400, "error_message": "Invalid scope field(s): basic"}

    It looks like it wants a scope item called "basic", I added one to the controller JS, but that doesn't seem to work either and I get the same error. Any ideas?

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 11, 2021 @ 13:11
    Anders Bjerner
    0

    Hi Tim,

    This will not work anymore. Instagram removed their Platform API in favor of newer APIs.

    Due to lack of time and things moving towards Umbraco 8, I have no plans to update the V7 package to use the new APIs.

    If you skip the Umbraco package, you may be able to get something to work with this package instead (it's not an Umbraco package): https://github.com/abjerner/Skybrud.Social.Instagram

    You can see an example for getting recent media using the newer Basic Display API here:

    https://social.skybrud.dk/instagram/basic-display-api/endpoints/users/getting-recent-media-of-a-user/

  • Tim 43 posts 197 karma points
    Mar 11, 2021 @ 14:30
    Tim
    0

    Hi Anders,

    That's what I was afraid of, thanks for getting back to me so quickly!

    The basic display API example looks like exactly what I'm after, I just need to display the last few posts for a given user!

    Looking at that example, how does it know which user to get the information for? I don't see a user in that example. Also, does it require any kind of authentication? Or is it just a case of calling that code and you'll get the latest media?

    In my example, I have a site for a client, and I want to get and list the last X posts from their company Instagram feed.

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 11, 2021 @ 15:38
    Anders Bjerner
    0

    Hi again,

    Honestly this can feel like quite a battle to set up correctly. We have yet to get an app approved by Facebook.

    If you're control of the Instagram account in question, you can create a Facebook app, let it stay in test mode, and then add the client's Instagram account as a tester. You can read more about that here:

    https://developers.facebook.com/docs/instagram-basic-display-api/overview#instagram-testers

    When the Instagram account has approved the test invite, you can generate an access token from the backoffice by logging in with the username and password of the Instagram account. This goes against the principle that the client should share their Instagram login information with you, but currently that's the best way I've found so far.

    Alternatively you could tell the client to set up the Facebook app themselves, and go through the same steps to get the access token. That way they don't have to share their login information - but it's quite a technical approach, which is why I choose not to go this way.

    As a third option, I think you technically should be able to add their Instagram account as a test account, and then set up an authentication page for them to login with, and then save the access token somewhere safe. My Instagram package should support that, but I don't currently have an example for setting up such an authentication page.

    If you do manage to obtain an access token through the Facebook control panel, it will be a long lived access token, which means it expires in roughly 60 days. As long as the access token hasn't yet expired, you can exchange one long lived access token for another:

    https://github.com/abjerner/Skybrud.Social.Instagram/blob/master/src/Skybrud.Social.Instagram/BasicDisplay/OAuth/InstagramBasicDisplayClient.cs#L190

    I recently set this up for a client, so I have saved the date of the current access token, and each time I'm pulling recent media from the API, I start out with checking whether the access token will soon expire, and if it does, I exchange the current access token with a new one. So far this seems to run smoothly.

    I hope this makes at least some sense 😉

  • Tim 43 posts 197 karma points
    Mar 11, 2021 @ 15:47
    Tim
    0

    Thanks Anders!

    That makes total sense. I was reading the Instagram API docs and the whole thing seems quite fiddly to set up. I'll give some of that a go and see if I can get it to work correctly!

    One more quick question if I may! Using Skybrud.Social.Twitter, is there a way to specify that it should return the FULL text of the tweets when you get a users latest tweets and not the truncated versions?

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 11, 2021 @ 15:50
    Anders Bjerner
    1

    Yes, you can specify a tweet mode:

    https://social.skybrud.dk/twitter/extended-tweets/

    IMO it seems like a bit weird approach, but I think Twitter made it this way for legacy support.

  • Anders Bjerner 487 posts 2989 karma points MVP 7x admin c-trib
    Mar 11, 2021 @ 16:05
    Anders Bjerner
    100

    If it helps anything, I found that I had this Razor view in my test setup.

    Although it could use some more comments explaining the various bits, it shows how to set up an authentication page:

    https://gist.github.com/abjerner/5d578d4e2649b1ab1829921fdbf81719

    If your app is still in test mode, Instagram accounts added as test user should still be able to log in (IIRC).

  • Tim 43 posts 197 karma points
    Mar 12, 2021 @ 10:49
    Tim
    0

    Thanks Anders!

    I've managed to get it all working I think! Thanks for your help :)

Please Sign in or register to post replies

Write your reply to:

Draft