I'm working with the Weibo API, and access_tokens expire after seven days. They claim that there is a way that there should be a way to auto-refresh the token, but I can't find any documentation on it... has anyone dealt with this? (We aren't using the Weibo SDK, so we do not have a refresh_token)
Related
We have been searching and searching to find examples of how to get an OAuth token in al code in our codeunit. We can successfully get the token in Postman, so I know all the credentials are correct. But finding examples on the web of how to do this has proven to be extremely difficult.
I did find this .al page from Microsoft that looks like it has an example using OAuth2.AcquireTokenWithClientCredentials but we can't get it to work. https://github.com/microsoft/BCTech/blob/master/samples/OAuth2Flows/TestOAuth2Flows.Page.al
Does anyone have a working example of this?
Kauffmann has a good blog post on this. It's talking about calling BC with an OAuth token, but the same principle applies.
Are you able to get the OAuth token in AL, and just have trouble using it to authenticate the request? If so, try this from the blog post:
Client.DefaultRequestHeaders.Add('Authorization', GetAuthenticationHeaderValue(AccessToken));
Client.DefaultRequestHeaders.Add('Accept', 'application/json');
If you can't get the token, I'd recommend looking at the OAuth2 codeunit.
I'm using google calendar api to addd events tocalendar. When I'm using oauth2.0, its asking for oauth and working properly. but after 2 0r 3 try, its failing, it shows invalied token error. And again after some times it work properly.
And if I use the token stored, its asking for oauth2 for the first 1 or 2 attempts and its fine. but its not asking for oauth and no events are being created. agin after some tries its asking for oauth2.
I didn't get any Idea why its happening so. Is there any solution?
This is probably occurring because your tokens are expiring. Include access=offline and prompt=consent in the authorization code link and it will probably start to work. Also make sure to refresh your token of the original access token fails and call the API with the new access token.
I work with Pathfix and it takes off the exact hassle for you if you want to save some time with the OAuth dance :)
I'm trying to write a Zap which will get events from a Google Calendar for the current week and generate a string describing when I'm in the office "Mon, Wed, Fri". The only thing that's stumping me is step 0. How do I auth for the Google Calendar API in a Zapier Code block? It appears that Google calendar only supports Oauth2.0 and only gives out short-lived tokens but I want this scheduled job to only run in the background and have no recourse for user-interaction. Is there any way to generate a long-lived access token?
David here, from the Zapier Platform team.
Unfortunately, that's not something that's easily doable. Part of what Zapier does for you is refresh the tokens and ensure everything is running as expected. Searching for a bunch of data (this week's events) isn't really in the zapier wheelhouse at this time.
If you're only concerned with new events, you could set up a "new event" trigger that adds the date of the event into Storage and a second zap that runs weekly, reads storage, figures out what dates are busy, and generates your string. That wouldn't hold up for recurring events though, so it may not be what you're looking for.
Alternatively, you could try and do the refresh loop in your code block, but that's really tough. You'd need somewhere to persist the token (while Storage technically works, it's open to the public so it's not a great place to store creds, even if they are hard to find). You could try your request, refresh if the token is stale, then send the eventually present value onto a later step.
Sorry I don't have better news. Let me know if you've got any other questions!
I'm working on a project where I pull in data from social media according to certain queries and analyze them. Currently I'm pulling in Instagram media data.
The only thing I want to do is to input a query and get JSON media/likes/comments.... I read the documentation of their API. I found that I couldn't get an access token without authorizing using my own account in a browser. I know there's gotta be a user, so I assume using my own account is fine. But the problem is that I don't want to get an access token manually from a browser.
Currently I'm hardcoding the access token. It will expire and I have to update it manually every time. I bet there's a better solution. Could someone help me out? Thanks.
class instagramFeed():
CLIENT_ID = "MY-APP-ID"
REDIRECT_URI = "MY-ORGANIZATIONS-URI"
ACCESS_TOKEN = "I MANUALLY GENERATE THIS TOKEN"
query = None
def __init__(self):
None
def get_data(self, query):
response = urllib2.urlopen("https://api.instagram.com/v1/tags/search?q="+query+"&access_token="+self.ACCESS_TOKEN)
It is not possible to get access_token without logging in on Instagram page, thats the whole point of oauth authentication.
You will have to manually get access_token and update, from my experience the Instagram access_token never expires, I have used it for 6 years. Only time you have to get new access_token is if Instagram revokes it because of suspicious activity detected. So as long as you use the API carefully without automating too much back-to back calls, you should be good with the same access_token.
I've created a web application that uses the Facebook API.
I would like to implement/create a method which is able to auto accept friend request of my own Facebook account.
Is this even possible and how to implement it in C#/ ASP.NET MVC?
Thank you in advance!
*I alreay read the Facebook Developers documentation https://developers.facebook.com/docs/howtos/requests/ but haven't been able to solve my 'problem'.
There is no API to send or approve friend requests.
There is the Friends Dialog but it sounds like you want this to work without user interaction which is impossible.
If you find some way to do this, you should report it via Facebook's whitehat bug bounty program, as it indicates a bug on Facebook's side.