Closed panjkov closed 6 years ago
@panjkov We'll be publishing some samples soon.
Any progress on this? There is obviously more to getting this working than is in the documentation...
Sorry for the delay: @anthony-france, @panjkov: Here's a sample that uses the Office Helpers: https://github.com/OfficeDev/Excel-Add-in-TypeScript-MailMerge.
If you are facing specific problems, please open an issue or ask on StackOverflow with the tag 'office-js' and 'office-js-helpers' and we'll make sure to get you up and running.
Note
In terms of code there are only three steps to get it working:
Create an instance of the authenticator
var authenticator = new OfficeHelpers.Authenticator()
Add an endpoint
authenticator.endpoints.add('Custom Endpoint', { /* config */})
authenticator.endpoints.useMicrosoftAuth('clientId', {/* optional overrides such as scope etc */})
Invoke the library
/* Wrap your code inside of so that your Add-in doesn't run inside of the AuthDialog */
if(!OfficeHelpers.Authenticator.isAuthDialog()) {
/*Invoke the auth*/
await authenticator.authenticate('CustomEndpoint');
/* or */
await authenticator.authenticate('Microsoft');
}
Project 404s
@afrance Sorry about that. We discovered in February that the sample that @WrathOfZombies linked to https://github.com/OfficeDev/Excel-Add-in-TypeScript-MailMerge was very corrupt and so we made it private until we could get it fixed. @WrathOfZombies was not aware of this. The person who was going to do the fix left the team and we only now (thanks to you!) discovered it was never fixed. We will try to do this as soon as we can.
@afrance It may be a while before we can fix the MailMerge sample. In the meantime, @WrathOfZombies has pointed me to two other samples that use the Office helpers:
Can we reopen this and provide a complete example with JS?
@jcserracampos, I started down the path of writing an example but the problem was the number of variants in which we can use this library are many.. Rather if you could tell me what you are looking for specifically and what information was lacking from the docs, I can
Well, its probably the same issues I've had where everyone here seems to want to insist all you need to do is 'add these couple lines here and it just works' yet when its attempted it doesn't work.
All that's needed is a real working example that logs in correctly imo. People can say all day long that its just this line here, that line there and this one here and TaDA! Here people just ripped some line out of their functioning app as an example and considering I'm not the only one having issues getting the basic example up and running and to repeat myself for at least the third time, "there is something mote to it than 'just add couple lines'.
On Mon, Dec 18, 2017 at 11:42 AM, Bhargav Krishna notifications@github.com wrote:
Reopened #6 https://github.com/OfficeDev/office-js-helpers/issues/6.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-js-helpers/issues/6#event-1392600067, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYpAhi-gUYn3U0UYZa1ZHgdLiiB0wi9ks5tBqPsgaJpZM4LAGqA .
Personally, I'm trying to authenticate with Todoist so it isn't on the methods. I accomplished to obtain user's code, but I can't close response window and exchange code to user's token.
@afrance, Sorry to hear that. We are trying to achieve exactly that where it should be really simple and effortless to complete authentication. To help unblock both of you guys for the moment, here's a javascript sample. I'll publish a sample as soon I get some bandwidth to complete it.
$(document).ready(() => {
const authenticator = new OfficeHelpers.Authenticator();
/* Steps to define a custom endpoint. Note: Todoist however doesn't support OAuth Implicit flow */
authenticator.endpoints.add('Todoist', {
baseUrl: 'https://todoist.com', /* the base api url */
authorizeUrl: '/oauth/authorize', /* the authorize url segment */
redirectUrl: 'https://localhost:3000', /* redirect url that needs to be passed to the api & when the dialog needs to be closed, defaults to location.origin */
tokenUrl: 'https://mycustomwebservice.com', /* [Optional]: Since Todoist supports only auth code flow, we can point the library to send a HTTP POST with the code & state to a custom endpoint where we can exchange the code and return a JSON response with access_token & state */
clientId: '<client ID>', /* client Id */
scope: 'data:read', /* scope */
state: true /* generate a state randomly */
});
const authenticate = () => {
authenticator.authenticate('Todoist')
.then(token => {
console.log(token);
})
.catch(error => {
console.error(error);
});
};
$("#run").click(authenticate);
});
@jcserracampos: I am working on a new beta version of Office Helpers which solves the dialog not closing problem and you can try that version out from here: https://unpkg.com/@microsoft/office-js-helpers@0.8.0-beta.4/dist/office.helpers.min.js
There's now a working sample in the demo/
folder.
Hi Team,
The same sample code mentioned "WrathOfZombies commented on Dec 19, 2017" have been implemented but am not getting token response instead am getting 12002 error code. Redirect url should have been hosted?
Is there a working sample of using authenticator with Office addin?